From 46b349b3b06a6f199b2d0c60dd8ba94f9b5959c7 Mon Sep 17 00:00:00 2001 From: Jeremy Woertink Date: Wed, 14 Dec 2022 11:18:08 -0800 Subject: [PATCH] Adds a guard clause for if the _inputRef doesn't exist when the animationFrame is executed. Fixes #34 --- src/ninja-header.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ninja-header.ts b/src/ninja-header.ts index b43b693..4b298b5 100644 --- a/src/ninja-header.ts +++ b/src/ninja-header.ts @@ -121,7 +121,7 @@ export class NinjaHeader extends LitElement { } focusSearch() { - requestAnimationFrame(() => this._inputRef.value!.focus()); + requestAnimationFrame(() => (this._inputRef && this._inputRef.value!.focus())); } private _handleInput(event: Event) {