mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-15 18:31:06 +00:00
fix(list-box-menu-item): scroll item into view when using keyboard navigation (#1471)
Fixes #1470
This commit is contained in:
parent
740c8e1596
commit
7030300186
2 changed files with 6 additions and 2 deletions
|
@ -12,13 +12,17 @@
|
|||
|
||||
$: isTruncated = ref?.offsetWidth < ref?.scrollWidth;
|
||||
$: title = isTruncated ? ref?.innerText : undefined;
|
||||
$: if (highlighted && !ref?.matches(":hover")) {
|
||||
// Scroll highlighted item into view if using keyboard navigation
|
||||
ref.scrollIntoView({ block: "end" });
|
||||
}
|
||||
</script>
|
||||
|
||||
<div
|
||||
role="option"
|
||||
class:bx--list-box__menu-item="{true}"
|
||||
class:bx--list-box__menu-item--active="{active}"
|
||||
class:bx--list-box__menu-item--highlighted="{highlighted}"
|
||||
class:bx--list-box__menu-item--highlighted="{highlighted || active}"
|
||||
aria-selected="{active}"
|
||||
disabled="{disabled ? true : undefined}"
|
||||
{...$$restProps}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue