Skip to content

Commit

Permalink
fix(disabled): make disabled selected option state unchangeable #174
Browse files Browse the repository at this point in the history
  • Loading branch information
jordanjones243 authored and jason-capsule42 committed Oct 26, 2023
1 parent 0858b5d commit 7a76aec
Showing 1 changed file with 30 additions and 28 deletions.
58 changes: 30 additions & 28 deletions src/auro-menu.js
Expand Up @@ -209,35 +209,37 @@ class AuroMenu extends LitElement {
this.initItems();
}

this.resetOptionsStates();
if (this.items[this.index] && !this.items[this.index].hasAttribute('disabled')) {
this.resetOptionsStates();

if (this.index >= 0) {
const option = this.items[this.index];

// only handle options that are not disabled, hidden or static
if (option && this.optionInteractive(option)) {
// fire custom event if defined otherwise make selection
if (option.hasAttribute('event')) {
this.dispatchEvent(new CustomEvent(option.getAttribute('event'), {
bubbles: true,
cancelable: false,
composed: true,
}));

// this event needs to be removed after select and combobox are updated to use the new standard name
this.dispatchEvent(new CustomEvent('auroMenuCustomEventFired', {
bubbles: true,
cancelable: false,
composed: true,
}));

this.dispatchEvent(new CustomEvent('auroMenu-customEventFired', {
bubbles: true,
cancelable: false,
composed: true,
}));
} else {
this.handleLocalSelectState(option);
if (this.index >= 0) {
const option = this.items[this.index];

// only handle options that are not disabled, hidden or static
if (option && this.optionInteractive(option)) {
// fire custom event if defined otherwise make selection
if (option.hasAttribute('event')) {
this.dispatchEvent(new CustomEvent(option.getAttribute('event'), {
bubbles: true,
cancelable: false,
composed: true,
}));

// this event needs to be removed after select and combobox are updated to use the new standard name
this.dispatchEvent(new CustomEvent('auroMenuCustomEventFired', {
bubbles: true,
cancelable: false,
composed: true,
}));

this.dispatchEvent(new CustomEvent('auroMenu-customEventFired', {
bubbles: true,
cancelable: false,
composed: true,
}));
} else {
this.handleLocalSelectState(option);
}
}
}
}
Expand Down

0 comments on commit 7a76aec

Please sign in to comment.