Skip to content
This repository was archived by the owner on Sep 5, 2024. It is now read-only.

Commit 4f84137

Browse files
fix(menu): remove exception when async loading
Fixes #4687.
1 parent 0853f2c commit 4f84137

File tree

1 file changed

+11
-13
lines changed

1 file changed

+11
-13
lines changed

src/components/menu/js/menuServiceProvider.js

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -410,24 +410,22 @@ function MenuProvider($$interimElementProvider) {
410410
right: boundryNodeRect.right - MENU_EDGE_MARGIN
411411
};
412412

413-
var alignTarget, alignTargetRect, existingOffsets;
413+
var alignTarget, alignTargetRect = { top:0, left : 0, right:0, bottom:0 }, existingOffsets = { top:0, left : 0, right:0, bottom:0 };
414414
var positionMode = opts.mdMenuCtrl.positionMode();
415415

416416
if (positionMode.top == 'target' || positionMode.left == 'target' || positionMode.left == 'target-right') {
417-
// TODO: Allow centering on an arbitrary node, for now center on first menu-item's child
418417
alignTarget = firstVisibleChild();
419-
if (!alignTarget) {
420-
throw Error('Error positioning menu. No visible children.');
418+
if ( alignTarget ) {
419+
// TODO: Allow centering on an arbitrary node, for now center on first menu-item's child
420+
alignTarget = alignTarget.firstElementChild || alignTarget;
421+
alignTarget = alignTarget.querySelector('[md-menu-align-target]') || alignTarget;
422+
alignTargetRect = alignTarget.getBoundingClientRect();
423+
424+
existingOffsets = {
425+
top: parseFloat(containerNode.style.top || 0),
426+
left: parseFloat(containerNode.style.left || 0)
427+
};
421428
}
422-
423-
alignTarget = alignTarget.firstElementChild || alignTarget;
424-
alignTarget = alignTarget.querySelector('[md-menu-align-target]') || alignTarget;
425-
alignTargetRect = alignTarget.getBoundingClientRect();
426-
427-
existingOffsets = {
428-
top: parseFloat(containerNode.style.top || 0),
429-
left: parseFloat(containerNode.style.left || 0)
430-
};
431429
}
432430

433431
var position = {};

0 commit comments

Comments
 (0)