mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-15 10:21:05 +00:00
Fix dropdown combobox focus (#447)
* fix(combo-box): selecting a different combobox should focus the input * fix(dropdown): selecting a different dropdown should focus the button * fix(combo-box): focus input if related target attribute is not "searchbox"
This commit is contained in:
parent
222c7f2899
commit
f6877f3809
2 changed files with 7 additions and 8 deletions
|
@ -82,7 +82,7 @@
|
||||||
*/
|
*/
|
||||||
export let listRef = null;
|
export let listRef = null;
|
||||||
|
|
||||||
import { createEventDispatcher, afterUpdate } from "svelte";
|
import { createEventDispatcher, afterUpdate, tick } from "svelte";
|
||||||
import WarningFilled16 from "carbon-icons-svelte/lib/WarningFilled16";
|
import WarningFilled16 from "carbon-icons-svelte/lib/WarningFilled16";
|
||||||
import {
|
import {
|
||||||
ListBox,
|
ListBox,
|
||||||
|
@ -173,9 +173,11 @@
|
||||||
<ListBoxField
|
<ListBoxField
|
||||||
role="button"
|
role="button"
|
||||||
aria-expanded="{open}"
|
aria-expanded="{open}"
|
||||||
on:click="{() => {
|
on:click="{async () => {
|
||||||
if (disabled) return;
|
if (disabled) return;
|
||||||
open = true;
|
open = true;
|
||||||
|
await tick();
|
||||||
|
ref.focus();
|
||||||
}}"
|
}}"
|
||||||
id="{id}"
|
id="{id}"
|
||||||
name="{name}"
|
name="{name}"
|
||||||
|
@ -220,7 +222,8 @@
|
||||||
on:focus
|
on:focus
|
||||||
on:blur
|
on:blur
|
||||||
on:blur="{({ relatedTarget }) => {
|
on:blur="{({ relatedTarget }) => {
|
||||||
if (relatedTarget && relatedTarget.getAttribute('role') !== 'button') {
|
if (!open || !relatedTarget) return;
|
||||||
|
if (relatedTarget.getAttribute('role') !== 'button' && relatedTarget.getAttribute('role') !== 'searchbox') {
|
||||||
ref.focus();
|
ref.focus();
|
||||||
}
|
}
|
||||||
}}"
|
}}"
|
||||||
|
|
|
@ -189,11 +189,6 @@
|
||||||
change(-1);
|
change(-1);
|
||||||
}
|
}
|
||||||
}}"
|
}}"
|
||||||
on:blur="{({ relatedTarget }) => {
|
|
||||||
if (relatedTarget) {
|
|
||||||
ref.focus();
|
|
||||||
}
|
|
||||||
}}"
|
|
||||||
disabled="{disabled}"
|
disabled="{disabled}"
|
||||||
translateWithId="{translateWithId}"
|
translateWithId="{translateWithId}"
|
||||||
id="{id}"
|
id="{id}"
|
||||||
|
@ -213,6 +208,7 @@
|
||||||
on:click="{() => {
|
on:click="{() => {
|
||||||
selectedId = item.id;
|
selectedId = item.id;
|
||||||
selectedIndex = i;
|
selectedIndex = i;
|
||||||
|
ref.focus();
|
||||||
}}"
|
}}"
|
||||||
on:mouseenter="{() => {
|
on:mouseenter="{() => {
|
||||||
highlightedIndex = i;
|
highlightedIndex = i;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue