From 52ca103f46226fe1dc5d293af41e47388ce3d3a6 Mon Sep 17 00:00:00 2001 From: Alf Eaton Date: Tue, 26 Aug 2025 15:46:29 +0100 Subject: [PATCH] Improve handling of undefined root doc id in settings (#28108) GitOrigin-RevId: ba0c5b468b11c53440506f05af0550e55e0f3a23 --- .../js/features/editor-left-menu/hooks/use-root-doc-id.tsx | 6 ++---- .../settings/compiler-settings/root-document-setting.tsx | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/services/web/frontend/js/features/editor-left-menu/hooks/use-root-doc-id.tsx b/services/web/frontend/js/features/editor-left-menu/hooks/use-root-doc-id.tsx index 632a3b3ce7..113e77883a 100644 --- a/services/web/frontend/js/features/editor-left-menu/hooks/use-root-doc-id.tsx +++ b/services/web/frontend/js/features/editor-left-menu/hooks/use-root-doc-id.tsx @@ -12,9 +12,7 @@ export default function useRootDocId() { const setRootDocIdFunc = useCallback( async (newRootDocId: ProjectSettings['rootDocId']) => { - // rootDocId will be undefined on angular scope on initialisation - const allowUpdate = - typeof rootDocId !== 'undefined' && permissionsLevel !== 'readOnly' + const allowUpdate = permissionsLevel !== 'readOnly' if (allowUpdate) { try { @@ -24,7 +22,7 @@ export default function useRootDocId() { } } }, - [permissionsLevel, rootDocId, saveProjectSettings] + [permissionsLevel, saveProjectSettings] ) return { diff --git a/services/web/frontend/js/features/ide-redesign/components/settings/compiler-settings/root-document-setting.tsx b/services/web/frontend/js/features/ide-redesign/components/settings/compiler-settings/root-document-setting.tsx index 719ea4da5a..38801c9dd6 100644 --- a/services/web/frontend/js/features/ide-redesign/components/settings/compiler-settings/root-document-setting.tsx +++ b/services/web/frontend/js/features/ide-redesign/components/settings/compiler-settings/root-document-setting.tsx @@ -43,7 +43,7 @@ export default function RootDocumentSetting() { disabled={!write} options={validDocsOptions} onChange={setRootDocId} - value={rootDocId} + value={rootDocId ?? ''} translateOptions="no" /> )