Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(combobox): fix sporadic change event emitted on initialization #10952

Merged
merged 3 commits into from
Dec 4, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading