mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-15 02:11:05 +00:00
fix(header-search): blur input when active
is false (#1857)
This commit is contained in:
parent
decf966dd7
commit
6c9cf9e043
1 changed files with 2 additions and 2 deletions
|
@ -46,6 +46,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
$: if (active && ref) ref.focus();
|
$: if (active && ref) ref.focus();
|
||||||
|
$: if (!active && ref) ref.blur();
|
||||||
$: dispatch(active ? "active" : "inactive");
|
$: dispatch(active ? "active" : "inactive");
|
||||||
$: selectedResult = results[selectedResultIndex];
|
$: selectedResult = results[selectedResultIndex];
|
||||||
$: selectedId = selectedResult
|
$: selectedId = selectedResult
|
||||||
|
@ -116,9 +117,8 @@
|
||||||
break;
|
break;
|
||||||
case 'Escape':
|
case 'Escape':
|
||||||
if (value === '') {
|
if (value === '') {
|
||||||
// If the search bar is empty, deactivate and blur the input.
|
// If the search bar is empty, deactivate the input.
|
||||||
active = false;
|
active = false;
|
||||||
ref?.blur();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reset the search query but keep the search bar active.
|
// Reset the search query but keep the search bar active.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue