fix(nodes): preserve open settings after replacement

This commit is contained in:
Lucio Lelii 2026-09-29 21:18:37 +02:00
parent 95d33d218b
commit d4ab8f8fb1
2 changed files with 25 additions and 0 deletions

View File

@ -109,6 +109,17 @@ describe('GenericNodeComponent', () => {
expect(fixture.nativeElement.querySelector('.llm-modal-backdrop')).not.toBeNull();
});
it('restores open settings after a structural edit replaces the node', () => {
component.toggleNodeSettings();
expect(component.data.data.__nodeSettingsOpen).toBe(true);
// Replacement creates a new Angular component, whose local state starts closed.
component.nodeSettingsOpen = false;
(component as any).restorePersistedNodeSettingsState();
expect(component.nodeSettingsOpen).toBe(true);
});
describe('clearing an optional number', () => {
/** Opens the modal editor on a numeric path, as clicking the pen does. */
function openNumericEditor(path: string, current: unknown) {

View File

@ -337,6 +337,7 @@ export class GenericNodeComponent implements OnDestroy {
this.refreshValidationState();
this.refreshParameterFields();
this.restorePersistedNodeSettingsState();
this.restorePersistedFocusState();
void this.loadSchemaContext();
}
@ -374,6 +375,7 @@ export class GenericNodeComponent implements OnDestroy {
event?.preventDefault();
event?.stopPropagation();
this.nodeSettingsOpen = !this.nodeSettingsOpen;
this.syncPersistedNodeSettingsState();
this.cdr.markForCheck();
}
@ -839,6 +841,18 @@ export class GenericNodeComponent implements OnDestroy {
?? (typeof mostSevereValue === 'string' ? mostSevereValue : null);
}
/** A structural edit replaces the Rete node, so keep this UI-only state with its data. */
private restorePersistedNodeSettingsState() {
const nodeData = this.data?.data as Record<string, unknown> | undefined;
this.nodeSettingsOpen = nodeData?.['__nodeSettingsOpen'] === true;
}
private syncPersistedNodeSettingsState() {
const nodeData = this.data?.data as Record<string, unknown> | undefined;
if (!nodeData) return;
nodeData['__nodeSettingsOpen'] = this.nodeSettingsOpen;
}
private ensureBlockConfiguration(): Record<string, any> {
if (!this.data?.data) {
this.data.data = {};