Skip to content

Commit

Permalink
dropdown: add optional sync property to align popup width to trigger …
Browse files Browse the repository at this point in the history
…slot element width (#1935)

Co-authored-by: Nic Newdigate <nic.newdigate@vivantio.com>
  • Loading branch information
newdigate and Nic Newdigate committed Mar 25, 2024
1 parent 2878957 commit 5a89439
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/components/dropdown/dropdown.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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();

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 5a89439

Please sign in to comment.