From 557d65862d5fbf5b3ae9447e44d78604af525892 Mon Sep 17 00:00:00 2001 From: JC Franco Date: Thu, 5 Oct 2023 16:10:57 -0700 Subject: [PATCH] fix(combobox): fix issue causing value to be cleared when selecting an item (Windows + trackpad) (#7954) **Related Issue:** #7934 ## Summary Updates the component to consistently bail on blur handling logic if the input is blurred, but focus is still within the component. ### Notes * the regression was introduced by https://github.com/Esri/calcite-design-system/pull/7721/ * due to time constraints, testing will be tackled in a follow-up issue as it's not easy to reproduce in an E2E test. --- .../src/components/combobox/combobox.tsx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/calcite-components/src/components/combobox/combobox.tsx b/packages/calcite-components/src/components/combobox/combobox.tsx index be4f5a0cb5d..7ed26bc55bd 100644 --- a/packages/calcite-components/src/components/combobox/combobox.tsx +++ b/packages/calcite-components/src/components/combobox/combobox.tsx @@ -761,19 +761,19 @@ export class Combobox this.updateActiveItemIndex(targetIndex); } - setInactiveIfNotContained = (event: Event): void => { + private setInactiveIfNotContained = (event: Event): void => { const composedPath = event.composedPath(); + if (!this.open || composedPath.includes(this.el) || composedPath.includes(this.referenceEl)) { + return; + } + if (!this.allowCustomValues && this.textInput.value) { this.clearInputValue(); this.filterItems(""); this.updateActiveItemIndex(-1); } - if (!this.open || composedPath.includes(this.el) || composedPath.includes(this.referenceEl)) { - return; - } - if (this.allowCustomValues && this.text.trim().length) { this.addCustomChip(this.text); }