From b14d3d9a754b8f78541018aa8a7c7523479ea65b Mon Sep 17 00:00:00 2001 From: David Stone Date: Mon, 11 May 2026 16:29:00 -0600 Subject: [PATCH] fix(template-switching): tighten sentinel guard to allow sites with no current template to switch Fixes #1145 The guard at original_template_id <= 0 conflated two distinct states: - original_template_id === -1: the data() sentinel (v-init not yet run) - original_template_id === 0: a valid runtime state meaning the site has no current template Customers whose sites had no template_id assigned could never trigger the confirm panel because confirm_active could never become true. Changed the guard to original_template_id < 0, which covers only genuine not-yet-initialised sentinels while treating 0 as the valid value it is. The PHP side already handles original_template_id=0 correctly in views/ui/template-switching-current.php and the switch_template() AJAX handler, so this JS fix is sufficient to unblock the self-service recovery path for affected customers. --- assets/js/template-switching.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/assets/js/template-switching.js b/assets/js/template-switching.js index 7c9f5569c..51d867e12 100644 --- a/assets/js/template-switching.js +++ b/assets/js/template-switching.js @@ -161,8 +161,12 @@ * initialised" and bail out — the watcher will fire * again on the next legitimate template change. */ - // eslint-disable-next-line eqeqeq - if (this.original_template_id == -1 || this.original_template_id <= 0) { + // Only -1 is the "not yet bound" sentinel (the data() default). + // 0 is a real, valid state meaning "site has no current template" + // — the customer must still be able to pick a template from the + // grid in that case. Use < 0 to also cover any future negative + // sentinel without re-introducing the 0 foot-gun. + if (this.original_template_id < 0) { return;