Et2Select + Search: Always need to bind our own change handler to catch & cancel search textbox changes or they bubble

This commit is contained in:
nathan 2022-07-07 10:47:14 -06:00
parent 4936c0e043
commit dc8809ef87

View File

@ -448,16 +448,18 @@ export const Et2WithSearchMixin = <T extends Constructor<LitElement>>(superclass
this.addEventListener("sl-blur", this._handleSearchAbort);
this.addEventListener("sl-select", this._handleSelect);
this.addEventListener("sl-clear", this._handleClear)
// Need our own change to catch the change event from search input
this.addEventListener("change", this._handleChange);
this.updateComplete.then(() =>
{
// Search messes up event order. Since it throws its own bubbling change event,
// selecting an option fires 2 change events - 1 before the widget is finished adjusting, losing the value
// We catch all change events, then call this._oldChange only when value changes
this.removeEventListener("change", this._oldChange);
// Need our own change to catch the change event from search input
this.addEventListener("change", this._handleChange);
});
this._searchButtonNode.addEventListener("click", this._handleSearchButtonClick);
}