Skip to content

Commit

Permalink
feat(cxl-ui): [cxl-marketing-nav] resize child menus if they are shor…
Browse files Browse the repository at this point in the history
…ter than their parent
  • Loading branch information
anoblet committed Feb 23, 2023
1 parent 882d465 commit 1eb4302
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions packages/cxl-ui/src/components/cxl-marketing-nav.js
Original file line number Diff line number Diff line change
Expand Up @@ -252,10 +252,18 @@ export class CXLMarketingNavElement extends LitElement {
const previousOverlay = overlays[overlays.length - 2];
const previousListBox = previousOverlay.querySelector('vaadin-context-menu-list-box');

// Reset list box height.
listBox.style.height = null;

requestAnimationFrame(() => {
if (listBox.offsetHeight > previousListBox.offsetHeight) {
overlay.style.top = topLevelOverlay.style.top;
// Check if the child list box is shorter then the parent's list box.
if (listBox.offsetHeight < previousListBox.offsetHeight) {
// Set the child list box height to the parent's list box height.
listBox.style.height = `${previousListBox.offsetHeight}px`;
}

// Align the child overlay to the top of the top level overlay.
overlay.style.top = topLevelOverlay.style.top;
});
}

Expand Down

0 comments on commit 1eb4302

Please sign in to comment.