Просмотр исходного кода

Improve handling of undefined root doc id in settings (#28108)

GitOrigin-RevId: ba0c5b468b11c53440506f05af0550e55e0f3a23
Alf Eaton 1 год назад
Родитель
Сommit
52ca103f46

+ 2 - 4
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(
   const setRootDocIdFunc = useCallback(
     async (newRootDocId: ProjectSettings['rootDocId']) => {
     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) {
       if (allowUpdate) {
         try {
         try {
@@ -24,7 +22,7 @@ export default function useRootDocId() {
         }
         }
       }
       }
     },
     },
-    [permissionsLevel, rootDocId, saveProjectSettings]
+    [permissionsLevel, saveProjectSettings]
   )
   )
 
 
   return {
   return {

+ 1 - 1
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}
       disabled={!write}
       options={validDocsOptions}
       options={validDocsOptions}
       onChange={setRootDocId}
       onChange={setRootDocId}
-      value={rootDocId}
+      value={rootDocId ?? ''}
       translateOptions="no"
       translateOptions="no"
     />
     />
   )
   )