fix(post-form): only auto-expand More options when a field deviates from default
initDisclosure auto-opened the More-options panel whenever any advanced field 'had a value', but the published toggle defaults ON, so a plain create form tripped it every load. A toggle now counts only when it deviates from its blueprint default (published: OFF is notable; force_connect/featured: ON is), so the panel stays collapsed on create. Edit mode still force-opens it separately. Rebuilt bundle via make build-assets. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Mpdu3Dt1iVoozHwAMyjrbn
This commit is contained in:
@@ -326,12 +326,20 @@ function initDisclosure() {
|
||||
wrappers[0].parentNode.insertBefore(details, wrappers[0]);
|
||||
wrappers.forEach(function (w) { details.appendChild(w); });
|
||||
|
||||
// A toggle only counts as an "advanced value" worth auto-expanding for when
|
||||
// it DEVIATES from its blueprint default. `published` defaults ON, so a plain
|
||||
// create form would otherwise trip this on every load and render More options
|
||||
// expanded. `published` is the sole default-ON toggle here, so its notable
|
||||
// state is OFF (a deliberate draft); the others (force_connect/featured)
|
||||
// default OFF, so theirs is ON. (Edit mode force-opens the panel elsewhere —
|
||||
// see initEditMode — so this only governs the create / draft-restore case.)
|
||||
var hasValue = wrappers.some(function (w) {
|
||||
var text = w.querySelector('input[type="text"]');
|
||||
if (text && text.value.trim()) return true;
|
||||
var toggle = w.querySelector('input[type="radio"]:checked');
|
||||
if (toggle && toggle.value && toggle.value !== '0') return true;
|
||||
return false;
|
||||
if (!toggle || !toggle.value) return false;
|
||||
var isPublished = /\[published\]$/.test(toggle.name || '');
|
||||
return isPublished ? toggle.value === '0' : toggle.value !== '0';
|
||||
});
|
||||
if (hasValue) details.open = true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user