diff --git a/.changeset/famous-points-care.md b/.changeset/famous-points-care.md new file mode 100644 index 0000000000..2bb5b73daf --- /dev/null +++ b/.changeset/famous-points-care.md @@ -0,0 +1,5 @@ +--- +'@baloise/ds-core': patch +--- + +**select**: update value after option change diff --git a/packages/core/src/components/bal-select/bal-select.tsx b/packages/core/src/components/bal-select/bal-select.tsx index 174ddad982..f4d04899db 100644 --- a/packages/core/src/components/bal-select/bal-select.tsx +++ b/packages/core/src/components/bal-select/bal-select.tsx @@ -268,7 +268,7 @@ export class Select implements ComponentInterface, Loggable, BalAriaFormLinking */ connectedCallback() { - const debounceUpdateOptions = debounce(() => this.updateOptions(), 0) + const debounceUpdateOptions = debounce(() => this.updateOptions(), 10) this.initialValue = this.value @@ -477,7 +477,7 @@ export class Select implements ComponentInterface, Loggable, BalAriaFormLinking */ private waitForOptionsAndThenUpdateRawValuesTimer?: NodeJS.Timeout - private async waitForOptionsAndThenUpdateRawValues() { + private waitForOptionsAndThenUpdateRawValues = async () => { clearTimeout(this.waitForOptionsAndThenUpdateRawValuesTimer) await deepReady(this.el) const hasOptions = this.options.size > 0 @@ -519,6 +519,9 @@ export class Select implements ComponentInterface, Loggable, BalAriaFormLinking if (this.didInit && !this.remote) { this.validateAfterBlur() } + if (this.didInit && this.remote && this.options.size > 0) { + this.validateAfterBlur(true) + } } /** @@ -914,7 +917,7 @@ export class Select implements ComponentInterface, Loggable, BalAriaFormLinking } private handleKeyPress = async (ev: KeyboardEvent) => { - if (!this.isPopoverOpen && isSpaceKey(ev)) { + if (!this.isPopoverOpen) { preventDefault(ev) await this.open() } @@ -931,10 +934,6 @@ export class Select implements ComponentInterface, Loggable, BalAriaFormLinking if (!this.disabled && !this.readonly) { this.inputValue = (ev.target as HTMLInputElement).value - if (!this.isPopoverOpen) { - this.popoverElement.present() - } - this.focusIndex = 0 this.updateFocus() preventDefault(ev) diff --git a/packages/core/src/components/bal-select/test/bal-select.autocomplete.html b/packages/core/src/components/bal-select/test/bal-select.autocomplete.html new file mode 100644 index 0000000000..866073e4ec --- /dev/null +++ b/packages/core/src/components/bal-select/test/bal-select.autocomplete.html @@ -0,0 +1,67 @@ + + +
+ + + + + + + +