interface: correct modal stacking behaviour

This commit is contained in:
Liam Fitzgerald 2021-02-10 17:00:00 +10:00
parent 2f4de07435
commit 0995019ef9
No known key found for this signature in database
GPG Key ID: D390E12C61D1CFFB
3 changed files with 10 additions and 4 deletions

View File

@ -2,14 +2,15 @@ import { useEffect, RefObject } from "react";
export function useOutsideClick(
ref: RefObject<HTMLElement | null | undefined>,
onClick: () => void
onClick: () => void,
) {
useEffect(() => {
function handleClick(event: MouseEvent) {
const portalRoot = document.querySelector('#portal-root')!;
if (
ref.current &&
!ref.current.contains(event.target as any) &&
!document.querySelector("#portal-root")!.contains(event.target as any)
(!portalRoot.contains(ref.current) || portalRoot.contains(event.target as any))
) {
onClick();
}

View File

@ -129,6 +129,8 @@ const GraphNodeContent = ({ group, post, contacts, mod, description, index, remo
measure={() => {}}
group={group}
contacts={contacts}
groups={{}}
associations={{ graph: {}, groups: {}}}
msg={post}
fontSize='0'
pt='2'

View File

@ -12,6 +12,7 @@ import { deSig } from '~/logic/lib/util';
import defaultApps from '~/logic/lib/default-apps';
import {Associations, Contacts, Groups, Tile, Invites} from '~/types';
import {useOutsideClick} from '~/logic/lib/useOutsideClick';
import {Portal} from '../Portal';
interface OmniboxProps {
associations: Associations;
@ -264,6 +265,7 @@ export function Omnibox(props: OmniboxProps) {
}, [results, navigate, selected, props.contacts, props.notifications, props.invites]);
return (
<Portal>
<Box
backgroundColor='scales.black30'
width='100%'
@ -271,7 +273,7 @@ export function Omnibox(props: OmniboxProps) {
position='absolute'
top='0'
right='0'
zIndex='9'
zIndex={11}
display={props.show ? 'block' : 'none'}>
<Row justifyContent='center'>
<Box
@ -292,6 +294,7 @@ export function Omnibox(props: OmniboxProps) {
</Box>
</Row>
</Box>
</Portal>
);
}