diff --git a/src/components/dropdown/dropdown.component.ts b/src/components/dropdown/dropdown.component.ts index 84bdcf89..8796d921 100644 --- a/src/components/dropdown/dropdown.component.ts +++ b/src/components/dropdown/dropdown.component.ts @@ -3,6 +3,7 @@ import { classMap } from 'lit/directives/class-map.js'; import { getAnimation, setDefaultAnimation } from '../../utilities/animation-registry.js'; import { getTabbableBoundary } from '../../internal/tabbable.js'; import { html } from 'lit'; +import { ifDefined } from 'lit/directives/if-defined.js'; import { LocalizeController } from '../../utilities/localize.js'; import { property, query } from 'lit/decorators.js'; import { waitForEvent } from '../../internal/event.js'; @@ -102,6 +103,11 @@ export default class SlDropdown extends ShoelaceElement { */ @property({ type: Boolean }) hoist = false; + /** + * Syncs the popup width or height to that of the trigger element. + */ + @property({ reflect: true }) sync: 'width' | 'height' | 'both' | undefined = undefined; + connectedCallback() { super.connectedCallback(); @@ -409,6 +415,7 @@ export default class SlDropdown extends ShoelaceElement { shift auto-size="vertical" auto-size-padding="10" + sync=${ifDefined(this.sync ? this.sync : undefined)} class=${classMap({ dropdown: true, 'dropdown--open': this.open