Skip to content

Commit

Permalink
fix: use portal to make sure ellipsis menu opens on top of note list
Browse files Browse the repository at this point in the history
  • Loading branch information
Antonella Sgarlatta committed May 18, 2021
1 parent 350fc20 commit e4d7023
Showing 1 changed file with 26 additions and 21 deletions.
47 changes: 26 additions & 21 deletions app/assets/javascripts/components/NotesOptionsPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
DisclosureButton,
DisclosurePanel,
} from '@reach/disclosure';
import { Portal } from '@reach/portal';
import MoreIcon from '../../icons/ic-more.svg';
import { useRef, useState } from 'preact/hooks';
import { observer } from 'mobx-react-lite';
Expand Down Expand Up @@ -55,27 +56,31 @@ export const NotesOptionsPanel = observer(({ appState }: Props) => {
<VisuallyHidden>Actions</VisuallyHidden>
<MoreIcon className="fill-current block" />
</DisclosureButton>
<DisclosurePanel
onKeyUp={(event) => {
if (event.key === 'Escape' && !submenuOpen) {
setOpen(false);
buttonRef.current.focus();
}
}}
ref={panelRef}
style={{
...position,
}}
className="sn-dropdown sn-dropdown-anchor-right flex flex-col py-2"
>
{open && (
<NotesOptions
appState={appState}
closeOnBlur={closeOnBlur}
onSubmenuChange={onSubmenuChange}
/>
)}
</DisclosurePanel>
<Portal>
<div className="sn-component">
<DisclosurePanel
onKeyUp={(event) => {
if (event.key === 'Escape' && !submenuOpen) {
setOpen(false);
buttonRef.current.focus();
}
}}
ref={panelRef}
style={{
...position,
}}
className="sn-dropdown flex flex-col py-2"
>
{open && (
<NotesOptions
appState={appState}
closeOnBlur={closeOnBlur}
onSubmenuChange={onSubmenuChange}
/>
)}
</DisclosurePanel>
</div>
</Portal>
</Disclosure>
);
});
Expand Down

0 comments on commit e4d7023

Please sign in to comment.