From fa0a95122d911a00126b200fa38c406a1b23202e Mon Sep 17 00:00:00 2001 From: James MacWilliam Date: Mon, 21 Apr 2025 06:54:24 -0400 Subject: [PATCH] Perform an empty check on filtered items - when I return an `@something` from the select template, this method attempts to run on the result. This is fine if the result matches the value, but if I want to return the key of an item from the values set, this will run and the collection will be missing. --- src/Tribute.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Tribute.js b/src/Tribute.js index 603382e9..68fde55e 100755 --- a/src/Tribute.js +++ b/src/Tribute.js @@ -472,7 +472,7 @@ class Tribute { selectItemAtIndex(index, originalEvent) { index = parseInt(index); - if (typeof index !== "number" || isNaN(index)) return; + if (typeof index !== "number" || isNaN(index) || !this.current.filteredItems) return; let item = this.current.filteredItems[index]; let content = this.current.collection.selectTemplate(item); if (content !== null) this.replaceText(content, originalEvent, item);