From affeb2e2f4d4082daee348a7d15aff70ad50ceb9 Mon Sep 17 00:00:00 2001 From: metonym Date: Mon, 3 Oct 2022 19:08:07 -0700 Subject: [PATCH] fix(list-box-menu-item): avoid element reference error (#1507) Fixes #1505 Fixes #1503 --- src/ListBox/ListBoxMenuItem.svelte | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ListBox/ListBoxMenuItem.svelte b/src/ListBox/ListBoxMenuItem.svelte index 0679ba31..c0ce7ea2 100644 --- a/src/ListBox/ListBoxMenuItem.svelte +++ b/src/ListBox/ListBoxMenuItem.svelte @@ -12,7 +12,7 @@ $: isTruncated = ref?.offsetWidth < ref?.scrollWidth; $: title = isTruncated ? ref?.innerText : undefined; - $: if (highlighted && !ref?.matches(":hover")) { + $: if (highlighted && ref && !ref.matches(":hover")) { // Scroll highlighted item into view if using keyboard navigation ref.scrollIntoView({ block: "nearest" }); }