fix(palabras): panel abre en la 1a tab NO vacia (regresion Item 1)

Al quitar el campo Texto, el parrafo se queda sin Contenido y el efecto de
seleccion de tab podia CAER en Avanzado (carrera: Diseño vacio un instante al
montar) y quedarse ahi. Ahora un flag tabAuto mantiene la tab en la primera
no-vacia (Contenido->Diseño->Avanzado) mientras el usuario no clicke una, robusto
a que las secciones lleguen tarde. Verificado: parrafo abre en Diseño (3/3).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
alpha-0.1-sec-dom
dev 3 months ago
parent 028ddc187a
commit d4cef53e3a

@ -328,11 +328,16 @@
...extraFields.filter((f) => (f.tab ?? 'avanzado') === 'avanzado')
]);
let tab = $state('contenido');
// Keep the active tab on a NON-empty one: a plain paragraph has no Contenido
// fields (its text is edited directly in the canvas), so its panel opens on Diseño.
// While the tab is AUTO-selected (the user hasn't clicked one), keep it on the
// FIRST non-empty tab (Contenido → Diseño → Avanzado). Robust to sections
// arriving AFTER mount: a plain paragraph (no Contenido fields) lands on Diseño
// and never sticks on Avanzado just because Diseño was momentarily empty. Once
// the user picks a tab, `tabAuto` turns off and their choice persists.
let tabAuto = $state(true);
$effect(() => {
if (tab === 'contenido' && contenidoFields.length === 0)
tab = disenoSections.length ? 'diseño' : 'avanzado';
if (!tabAuto) return;
const next = contenidoFields.length ? 'contenido' : disenoSections.length ? 'diseño' : 'avanzado';
if (next !== tab) tab = next;
});
// ── Reset to defaults — per Diseño accordion section + per whole block. Clears
@ -1341,7 +1346,10 @@
<SHELL.Body {...SHELL.bodyProps}>
<Tabs
value={tab}
onValueChange={(v) => (tab = v)}
onValueChange={(v) => {
tabAuto = false;
tab = v;
}}
variant="segmented"
size="sm"
fitted

Loading…
Cancel
Save

Powered by TurnKey Linux.