fix(nodes): preserve open settings after replacement
This commit is contained in:
parent
95d33d218b
commit
d4ab8f8fb1
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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 = {};
|
||||
|
|
|
|||
Loading…
Reference in New Issue