Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions components/dropdown/dropdown-menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,15 +125,15 @@ class DropdownMenu extends ThemeMixin(DropdownPopoverMixin(LitElement)) {
this.#getMenuElement().focus();
}

#handleMenuResize(e) {
#handleMenuResize() {

if (this._mobile && this.mobileTray) {
this.maxHeight = null;
} else {
this.maxHeight = this.#maxHeightNonTray;
}

this.position(e.detail, { updateLocation: this.#initializingHeight });
this.position(undefined, { updateLocation: this.#initializingHeight });

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The handler was using the menu content rect to calculate positioning. This changes it so it uses the whole filter dropdown instead.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. I think the original assumption, before filter and a header was introduced, was that d2l-dropdown-menu size === d2l-menu size. This e.detail was meant to be an optimization so that the positioning logic would not have to measure it.

this.#initializingHeight = false;

const menu = this.#getMenuElement();
Expand All @@ -152,7 +152,6 @@ class DropdownMenu extends ThemeMixin(DropdownPopoverMixin(LitElement)) {
this._closeRadio = false;

const menu = this.#getMenuElement();
menu.resize();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Curious why this is no longer needed... ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

menu.resize only dispatches a resize event, and the element itself listens to that event and reacts. However, whenever the menu opens, the menu's resize observer dispatches a resize event too, so this just causes a redundant dispatch that may cause some weird sizing if animations are running.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome. Thanks. That might have been something that was previously needed before native ResizeObserver was supported.


// If dropdown-menu is opened on first render, do not focus
if (this.#initiallyOpenedSuppressFocus) this.#initiallyOpenedSuppressFocus = false;
Expand Down
Loading