From 941ce1f775bd63797a403334f62eeb89121f9a14 Mon Sep 17 00:00:00 2001 From: Jason Zimdars Date: Thu, 11 Dec 2025 09:38:34 -0600 Subject: [PATCH] Need to use `has*Target` to check for optional static targets to prevent console errors --- app/javascript/controllers/theme_controller.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/javascript/controllers/theme_controller.js b/app/javascript/controllers/theme_controller.js index 30e296dca..154bf4fc0 100644 --- a/app/javascript/controllers/theme_controller.js +++ b/app/javascript/controllers/theme_controller.js @@ -42,8 +42,8 @@ export default class extends Controller { #updateButtons() { const storedTheme = this.#storedTheme - if (this.lightButtonTarget) { this.lightButtonTarget.checked = (storedTheme === "light") } - if (this.darkButtonTarget) { this.darkButtonTarget.checked = (storedTheme === "dark") } - if (this.autoButtonTarget) { this.autoButtonTarget.checked = (storedTheme !== "light" && storedTheme !== "dark") } + if (this.hasLightButtonTarget) { this.lightButtonTarget.checked = (storedTheme === "light") } + if (this.hasDarkButtonTarget) { this.darkButtonTarget.checked = (storedTheme === "dark") } + if (this.hasAutoButtonTarget) { this.autoButtonTarget.checked = (storedTheme !== "light" && storedTheme !== "dark") } } }