Skip to content

Commit

Permalink
use CustomEvent to include name in event details
Browse files Browse the repository at this point in the history
Refs: #7374
  • Loading branch information
anicyne committed Mar 5, 2025
1 parent 802395d commit 99ace73
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
4 changes: 2 additions & 2 deletions packages/components/src/components/combobox/shadow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ export class KolCombobox implements ComboboxAPI {
};

private selectOption(option: string) {
this.controller.onFacade.onInput(new Event('input', { bubbles: true }), true, option);
this.controller.onFacade.onChange(new Event('change', { bubbles: true }), option);
this.controller.onFacade.onInput(new CustomEvent('input', { bubbles: true, detail: { name: this.state._name, value: option } }), true, option);
this.controller.onFacade.onChange(new CustomEvent('change', { bubbles: true, detail: { name: this.state._name, value: option } }), option);
this.controller.setFormAssociatedValue(option);
this.state._value = option;
this.refInput?.focus();
Expand Down
10 changes: 4 additions & 6 deletions packages/components/src/components/single-select/shadow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,18 +95,16 @@ export class KolSingleSelect implements SingleSelectAPI {
this.state._value = emptyValue;
this._inputValue = emptyValue;
this._filteredOptions = [...this.state._options];
this.controller.onFacade.onInput(new Event('input', { bubbles: true }), true, emptyValue);
this.controller.onFacade.onChange(new Event('change', { bubbles: true }), emptyValue);
this.controller.onFacade.onInput(new CustomEvent('input', { bubbles: true, detail: { name: this.state._name, value: emptyValue } }), true, emptyValue);
this.controller.onFacade.onChange(new CustomEvent('change', { bubbles: true, detail: { name: this.state._name, value: emptyValue } }), emptyValue);
}
}

private selectOption(option: Option<string>) {
this.state._value = option.value;
this._inputValue = option.label as string;

this.controller.onFacade.onInput(new Event('input', { bubbles: true }), false, option.value);
this.controller.onFacade.onChange(new Event('change', { bubbles: true }), option.value);

this.controller.onFacade.onInput(new CustomEvent('input', { bubbles: true, detail: { name: this.state._name, value: option.value } }), false, option.value);
this.controller.onFacade.onChange(new CustomEvent('change', { bubbles: true, detail: { name: this.state._name, value: option.value } }), option.value);
this._filteredOptions = [...this.state._options];

this.controller.setFormAssociatedValue(this.state._value);
Expand Down

0 comments on commit 99ace73

Please sign in to comment.