From 68442919d3779bd80afa1886f2a1e4f10584fbea Mon Sep 17 00:00:00 2001 From: sdarbinyan Date: Mon, 13 Jul 2026 15:57:39 +0400 Subject: [PATCH] fix(project-editor): preserve multilingual nav labels on edit updateLabel() previously overwrote NavigationItemConfig.label with a bare string via updateNavLink, destroying every other locale's translation whenever a localized label object was edited. Add a facade method updateNavLinkLabel() that inspects the existing label shape: plain strings are replaced as before, but localized objects only have the current default locale's key overwritten, leaving other locales intact. --- .../facade/project-editor.facade.ts | 32 +++++++++++++++++++ .../sections/navigation-section.component.ts | 2 +- 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/src/app/features/project-editor/facade/project-editor.facade.ts b/src/app/features/project-editor/facade/project-editor.facade.ts index 7edad35..07e56bb 100644 --- a/src/app/features/project-editor/facade/project-editor.facade.ts +++ b/src/app/features/project-editor/facade/project-editor.facade.ts @@ -179,6 +179,38 @@ export class ProjectEditorFacade { }); } + /** + * Updates a nav item's label without destroying other locales' translations. + * If the item's current label is a plain string (or unset), it's replaced outright. + * If it's already a NavigationLocalizedText object, only the current default + * locale's key is overwritten; every other locale key is preserved untouched. + */ + updateNavLinkLabel(target: 'header' | 'footer', id: string, value: string): void { + this.updateBootstrap(current => { + const list = current.navigation[target]; + if (!this.isFlatNavList(list)) { + return current; + } + const defaultLocale = current.localization.defaultLocale ?? 'en'; + return { + ...current, + navigation: { + ...current.navigation, + [target]: (list as NavigationItemConfig[]).map(item => { + if (item.id !== id) { + return item; + } + const currentLabel = item.label; + const nextLabel = currentLabel && typeof currentLabel === 'object' + ? { ...currentLabel, [defaultLocale]: value } + : value; + return { ...item, label: nextLabel }; + }), + }, + }; + }); + } + reorderNavLink(target: 'header' | 'footer', id: string, direction: -1 | 1): void { this.updateBootstrap(current => { const list = current.navigation[target]; diff --git a/src/app/features/project-editor/sections/navigation-section.component.ts b/src/app/features/project-editor/sections/navigation-section.component.ts index 54ad943..9e6e146 100644 --- a/src/app/features/project-editor/sections/navigation-section.component.ts +++ b/src/app/features/project-editor/sections/navigation-section.component.ts @@ -46,7 +46,7 @@ export class ProjectEditorNavigationSectionComponent { } updateLabel(target: 'header' | 'footer', id: string, value: string): void { - this.facade.updateNavLink(target, id, { label: value }); + this.facade.updateNavLinkLabel(target, id, value); } updateRoute(target: 'header' | 'footer', id: string, value: string): void {