fix: render change editor menu only if it is open (#894)

This commit is contained in:
Aman Harwara
2022-02-23 20:55:26 +05:30
committed by GitHub
parent 209bd99fe5
commit 5df3e59604
4 changed files with 44 additions and 60 deletions

View File

@@ -39,7 +39,7 @@ type AccordionMenuGroup<T> = {
export type EditorMenuItem = {
name: string;
component?: SNComponent;
isPremiumFeature?: boolean;
isEntitled: boolean;
};
export type EditorMenuGroup = AccordionMenuGroup<EditorMenuItem>;
@@ -162,8 +162,8 @@ export const ChangeEditorOption: FunctionComponent<ChangeEditorOptionProps> = ({
);
useEffect(() => {
setEditorMenuGroups(createEditorMenuGroups(editors));
}, [editors]);
setEditorMenuGroups(createEditorMenuGroups(application, editors));
}, [application, editors]);
useEffect(() => {
setSelectedEditor(application.componentManager.editorForNote(note));
@@ -248,15 +248,17 @@ export const ChangeEditorOption: FunctionComponent<ChangeEditorOptionProps> = ({
}}
className="sn-dropdown flex flex-col max-h-120 min-w-68 fixed overflow-y-auto"
>
<ChangeEditorMenu
application={application}
closeOnBlur={closeOnBlur}
currentEditor={selectedEditor}
setSelectedEditor={setSelectedEditor}
note={note}
groups={editorMenuGroups}
isOpen={changeEditorMenuVisible}
/>
{changeEditorMenuOpen && (
<ChangeEditorMenu
application={application}
closeOnBlur={closeOnBlur}
currentEditor={selectedEditor}
setSelectedEditor={setSelectedEditor}
note={note}
groups={editorMenuGroups}
isOpen={changeEditorMenuVisible}
/>
)}
</DisclosurePanel>
</Disclosure>
);