From 4b60a1698b85b94729501fd732ced6b81fa48954 Mon Sep 17 00:00:00 2001 From: Matthew Robertson Date: Wed, 9 Feb 2022 10:40:24 -0500 Subject: [PATCH] Cleans up scrollTo's element finding This commit replaces a somewhat convoluted query chain with a single querySelector to fetch the specific element we want to focus on. This feels slightly cleaner to my eyes, but has the added benefit of ensuring it works correctly with something like "vertical-collection", which occluding certain elements from the list for performance reasons. This was causing keyboard-navigation to fail unexpectedly, since `.item(19)` was no longer guaranteed to be the item with `data-option-index='19'`, or even to exist. --- addon/components/power-select.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addon/components/power-select.ts b/addon/components/power-select.ts index 357f396ce..515b48c81 100644 --- a/addon/components/power-select.ts +++ b/addon/components/power-select.ts @@ -430,7 +430,7 @@ export default class PowerSelect extends Component { if (index === -1) { return; } - let optionElement = (optionsList.querySelectorAll('[data-option-index]') as NodeListOf).item(index); + let optionElement = optionsList.querySelector(`[data-option-index='${index}']`) as HTMLElement; if (!optionElement) { return; }