mirror of
https://github.com/antebudimir/feishin.git
synced 2025-12-31 10:03:33 +00:00
remove all node selectors in useClickOutside
This commit is contained in:
parent
78dc89303d
commit
751ad55d02
1 changed files with 3 additions and 9 deletions
|
|
@ -103,19 +103,13 @@ export const ContextMenuProvider = ({ children }: ContextMenuProviderProps) => {
|
|||
const { t } = useTranslation();
|
||||
const [opened, setOpened] = useState(false);
|
||||
|
||||
const [contextMenuRef, setContextMenuRef] = useState<HTMLDivElement | null>(null);
|
||||
const [ratingsRef, setRatingsRef] = useState<HTMLDivElement | null>(null);
|
||||
const [rating, setRating] = useState<number>(0);
|
||||
|
||||
useEffect(() => {
|
||||
setRating(0);
|
||||
}, [opened]);
|
||||
|
||||
const clickOutsideRef = useClickOutside(
|
||||
() => setOpened(false),
|
||||
['mousedown', 'touchstart'],
|
||||
[contextMenuRef, ratingsRef],
|
||||
);
|
||||
const clickOutsideRef = useClickOutside(() => setOpened(false), ['mousedown', 'touchstart']);
|
||||
|
||||
const viewport = useViewportSize();
|
||||
const server = useCurrentServer();
|
||||
|
|
@ -882,7 +876,7 @@ export const ContextMenuProvider = ({ children }: ContextMenuProviderProps) => {
|
|||
leftIcon: <Icon icon="star" />,
|
||||
onClick: () => {},
|
||||
rightIcon: (
|
||||
<Group ref={setRatingsRef as any}>
|
||||
<Group>
|
||||
<Rating
|
||||
onChange={(e) => {
|
||||
handleUpdateRating(e);
|
||||
|
|
@ -950,7 +944,7 @@ export const ContextMenuProvider = ({ children }: ContextMenuProviderProps) => {
|
|||
<AnimatePresence>
|
||||
{opened && (
|
||||
<ContextMenu minWidth={125} ref={mergedRef} xPos={ctx.xPos} yPos={ctx.yPos}>
|
||||
<Stack gap={0} ref={setContextMenuRef}>
|
||||
<Stack gap={0}>
|
||||
<Stack gap={0} onClick={closeContextMenu}>
|
||||
{ctx.menuItems?.map((item) => {
|
||||
return (
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue