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

@@ -49,8 +49,8 @@ export const ChangeEditorButton: FunctionComponent<Props> = observer(
const [currentEditor, setCurrentEditor] = useState<SNComponent>();
useEffect(() => {
setEditorMenuGroups(createEditorMenuGroups(editors));
}, [editors]);
setEditorMenuGroups(createEditorMenuGroups(application, editors));
}, [application, editors]);
useEffect(() => {
if (note) {
@@ -121,15 +121,17 @@ export const ChangeEditorButton: FunctionComponent<Props> = observer(
className="sn-dropdown sn-dropdown--animated min-w-68 max-h-120 max-w-xs flex flex-col overflow-y-auto fixed"
onBlur={closeOnBlur}
>
<ChangeEditorMenu
closeOnBlur={closeOnBlur}
application={application}
isOpen={open}
currentEditor={currentEditor}
setSelectedEditor={setCurrentEditor}
note={note}
groups={editorMenuGroups}
/>
{open && (
<ChangeEditorMenu
closeOnBlur={closeOnBlur}
application={application}
isOpen={open}
currentEditor={currentEditor}
setSelectedEditor={setCurrentEditor}
note={note}
groups={editorMenuGroups}
/>
)}
</DisclosurePanel>
</Disclosure>
</div>