[assist] Fix js error in the context popover when showing the popover is slow
@@ -1346,8 +1346,18 @@ from metadata.conf import has_navigator
var rightX, leftX, leftDiff, rightDiff, topY, bottomY, topDiff, bottomDiff;
var redrawHeaders = false;
+ var initOriginalValues = function (attempt) {
+ if (attempt > 20) {
+ return;
+ }
window.setTimeout(function () {
var offset = $('.hue-popover').offset();
+ if (!offset) {
+ // Popover isn't visible yet, wait a bit and try again
+ attempt++;
+ initOriginalValues(attempt);
+ return;
+ }
if (orientation === 'right') {
offset.left -= 5;
} else if (orientation === 'bottom') {
@@ -1361,7 +1371,10 @@ from metadata.conf import has_navigator
originalRightX = offset.left + originalWidth;
originalTopY = offset.top;
originalBottomY = offset.top + originalHeight;
- }, 0);
+ }, attempt * 20);
+ };
+
+ initOriginalValues(0);
self.saveSize = function () {
apiHelper.setInTotalStorage('assist', 'popover.size', {
