mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-15 10:21:05 +00:00
fix(combo-box): fix typing when refocusing input
Fixes a bug where the input `value` is immediately reset when re-focusing the input. The `value` resetting is necessary to support programmatically clearing the value, but it should only execute if the input is not currently focused.
This commit is contained in:
parent
0e1177f398
commit
9e3d83031e
2 changed files with 27 additions and 3 deletions
|
@ -175,12 +175,18 @@
|
|||
filteredItems = [];
|
||||
if (!selectedItem) {
|
||||
selectedId = undefined;
|
||||
value = "";
|
||||
// Only reset value if the input is not focused
|
||||
if (!ref.contains(document.activeElement)) {
|
||||
value = "";
|
||||
}
|
||||
highlightedIndex = -1;
|
||||
highlightedId = undefined;
|
||||
} else {
|
||||
// programmatically set value
|
||||
value = itemToString(selectedItem);
|
||||
// Only set value if the input is not focused
|
||||
if (!ref.contains(document.activeElement)) {
|
||||
// programmatically set value
|
||||
value = itemToString(selectedItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue