Skip to content

Commit

Permalink
fix(Dropdown): disable the trigger element if the dropdown have `disa…
Browse files Browse the repository at this point in the history
…ble="true"` (#878)
  • Loading branch information
Cata1989 authored Feb 27, 2024
1 parent 02926ca commit 54c87fd
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions packages/beeq/src/components/dropdown/bq-dropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,14 @@ export class BqDropdown {
this.bqOpen.emit({ open: this.open });
}

@Watch('disabled')
handleDisabledChange() {
if (!this.triggerElem) return;

// set 'disabled' attribute based on 'this.disabled' value, ensuring consistent state handling
this.disabled ? this.triggerElem?.setAttribute('disabled', 'true') : this.triggerElem?.removeAttribute('disabled');
}

// Events section
// Requires JSDocs for public API documentation
// ==============================================
Expand All @@ -82,6 +90,7 @@ export class BqDropdown {

componentDidLoad() {
this.triggerElem = this.el.querySelector('[slot="trigger"]');
this.handleDisabledChange();
}

// Listeners
Expand Down

0 comments on commit 54c87fd

Please sign in to comment.