Fix API panel re-injecting field defaults over cleared values
startPluginEdit pre-filled any empty field with its descriptor default, treating an explicitly cleared field (stored "") the same as one never set (undefined). So a saved-blank OpenSky bounding box reappeared as the default 50.5,3.2,53.7,7.3 on reopen (and would be re-persisted on save). Only inject a default when the field has never been stored (undefined), so intentional blanks stay blank. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
125d0ccc7d
commit
6a007fd25e
@@ -271,9 +271,11 @@ async function togglePlugin(p) {
|
||||
function startPluginEdit(p) {
|
||||
editingPlugin.value = editingPlugin.value === p.name ? "" : p.name;
|
||||
const cfg = { ...(p.config || {}) };
|
||||
// Preselect each field's effective default when nothing is stored yet.
|
||||
// Preselect each field's effective default only when it has never been stored.
|
||||
// An explicitly cleared field (stored as "") is left blank, so it stays blank on
|
||||
// save instead of the default being re-materialised on every reopen.
|
||||
for (const f of p.configFields || []) {
|
||||
if ((cfg[f.key] === undefined || cfg[f.key] === "") && f.default) cfg[f.key] = f.default;
|
||||
if (cfg[f.key] === undefined && f.default) cfg[f.key] = f.default;
|
||||
}
|
||||
editConfig.value = cfg;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user