Skip to content

Commit

Permalink
fix(Dropdown): optimize logic of disabled attribute based on componen…
Browse files Browse the repository at this point in the history
…t state
  • Loading branch information
Cata1989 committed Feb 26, 2024
1 parent d241e07 commit 9b99c79
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions packages/beeq/src/components/dropdown/bq-dropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,11 @@ export class BqDropdown {
}

@Watch('disabled')
handleDisabledChange(newValue: boolean) {
const bqButton = document.querySelector('bq-button');
if (!bqButton) return;
handleDisabledChange() {
if (!this.triggerElem) return;

bqButton.disabled = newValue;
// 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
Expand All @@ -90,7 +90,7 @@ export class BqDropdown {

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

// Listeners
Expand Down

0 comments on commit 9b99c79

Please sign in to comment.