From da82a465911e32887732daa379692eb497039c90 Mon Sep 17 00:00:00 2001 From: MarekWo Date: Sun, 26 Apr 2026 20:18:44 +0200 Subject: [PATCH] fix(regions): use explicit None entry to clear default in Region Registry MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replace the click-the-selected-radio-again gesture with a top-row "None — use firmware default" radio, mirroring the per-channel region picker. Users found the toggle gesture unintuitive; an explicit option matches the picker pattern they already know. Co-Authored-By: Claude Opus 4.7 --- app/static/js/app.js | 30 ++++++++++++++++-------------- app/templates/base.html | 2 +- 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/app/static/js/app.js b/app/static/js/app.js index e1e12ab..e345a85 100644 --- a/app/static/js/app.js +++ b/app/static/js/app.js @@ -2863,7 +2863,20 @@ function renderRegionsList() { listEl.innerHTML = '
No regions defined. Add one below.
'; return; } - listEl.innerHTML = regions.map(r => { + const noDefault = !regions.some(r => r.is_default); + const noneRow = ` +
+
+ +
+
+ None — use firmware default +
+
+ `; + const regionRows = regions.map(r => { const isDefault = r.is_default ? 'checked' : ''; const keyShort = (r.key_hex || '').slice(0, 8) + '…'; return ` @@ -2871,8 +2884,7 @@ function renderRegionsList() {
+ onchange="setDefaultRegion(${r.id})">
${escapeHtml(r.name)}
@@ -2886,6 +2898,7 @@ function renderRegionsList() {
`; }).join(''); + listEl.innerHTML = noneRow + regionRows; } async function addRegion(name, inputEl) { @@ -2928,17 +2941,6 @@ async function deleteRegion(id, name) { } } -function handleRegionRadioClick(id, inputEl) { - // Click on the already-selected default clears the default; otherwise sets it. - const wasDefault = (window.regionRegistry || []).some(r => r.id === id && r.is_default); - if (wasDefault) { - inputEl.checked = false; - clearDefaultRegion(); - } else { - setDefaultRegion(id); - } -} - async function setDefaultRegion(id) { try { const resp = await fetch(`/api/regions/${id}/default`, { method: 'POST' }); diff --git a/app/templates/base.html b/app/templates/base.html index a71a71e..c0a00c0 100644 --- a/app/templates/base.html +++ b/app/templates/base.html @@ -792,7 +792,7 @@
- Tip: pick the default region via the radio button. Click the selected radio again to clear it. The default is also pushed to the firmware so any untagged channel uses it. + Tip: pick the default region via the radio button, or select None to fall back to the firmware default. The chosen region is also pushed to the firmware so any untagged channel uses it.