Skip to content

Commit

Permalink
fix(combobox): fix sporadic change event emitted on initialization
Browse files Browse the repository at this point in the history
  • Loading branch information
jcfranco committed Dec 3, 2024
1 parent c43ed4c commit 2765410
Showing 1 changed file with 3 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,6 @@ export class ComboboxItem extends LitElement implements InteractiveComponent {

// #endregion

// #region Private Properties

private _selected = false;

// #endregion

// #region State Properties

@state() hasContent = false;
Expand Down Expand Up @@ -94,18 +88,7 @@ export class ComboboxItem extends LitElement implements InteractiveComponent {
@property() scale: Scale = "m";

/** When `true`, the component is selected. */
@property({ reflect: true })
get selected(): boolean {
return this._selected;
}

set selected(selected: boolean) {
const oldSelected = this._selected;
if (selected !== oldSelected) {
this._selected = selected;
this.selectedWatchHandler();
}
}
@property({ reflect: true }) selected: boolean = false;

/**
* Specifies the selection mode of the component, where:
Expand Down Expand Up @@ -181,6 +164,7 @@ export class ComboboxItem extends LitElement implements InteractiveComponent {
Docs: https://qawebgis.esri.com/arcgis-components/?path=/docs/lumina-transition-from-stencil--docs#watching-for-property-changes */
if (
(changes.has("disabled") && (this.hasUpdated || this.disabled !== false)) ||
(changes.has("selected") && (this.hasUpdated || this.selected !== false)) ||
changes.has("textLabel")
) {
this.calciteInternalComboboxItemChange.emit();
Expand All @@ -194,9 +178,6 @@ export class ComboboxItem extends LitElement implements InteractiveComponent {
// #endregion

// #region Private Methods
private selectedWatchHandler(): void {
this.calciteComboboxItemChange.emit();
}

private handleDefaultSlotChange(event: Event): void {
this.hasContent = slotChangeHasContent(event);
Expand All @@ -210,6 +191,7 @@ export class ComboboxItem extends LitElement implements InteractiveComponent {
}

this.selected = !this.selected;
this.calciteComboboxItemChange.emit();
}

private itemClickHandler(): void {
Expand Down

0 comments on commit 2765410

Please sign in to comment.