mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-15 18:31:06 +00:00
fix: improve ComboBox tab key handling
This commit is contained in:
parent
0e1177f398
commit
f21aa222fb
1 changed files with 7 additions and 2 deletions
|
@ -175,7 +175,6 @@
|
||||||
filteredItems = [];
|
filteredItems = [];
|
||||||
if (!selectedItem) {
|
if (!selectedItem) {
|
||||||
selectedId = undefined;
|
selectedId = undefined;
|
||||||
value = "";
|
|
||||||
highlightedIndex = -1;
|
highlightedIndex = -1;
|
||||||
highlightedId = undefined;
|
highlightedId = undefined;
|
||||||
} else {
|
} else {
|
||||||
|
@ -283,7 +282,13 @@
|
||||||
open = true;
|
open = true;
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
on:keydown
|
on:keydown={(e) => {
|
||||||
|
// If there's a selection and user types a printable character, clear selection immediately
|
||||||
|
if (e.key.length === 1 && selectedItem) {
|
||||||
|
selectedId = undefined;
|
||||||
|
selectedItem = undefined;
|
||||||
|
}
|
||||||
|
}}
|
||||||
on:keydown|stopPropagation={(e) => {
|
on:keydown|stopPropagation={(e) => {
|
||||||
const { key } = e;
|
const { key } = e;
|
||||||
if (["Enter", "ArrowDown", "ArrowUp"].includes(key)) {
|
if (["Enter", "ArrowDown", "ArrowUp"].includes(key)) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue