mod(whiteboard): close tool panel when select tool

This commit is contained in:
austaras authored and Austaras committed 2022-08-23 17:04:20 +08:00
1 parent 7b4999225a
commit eedb4864df
9 files changed
+55 -34

No files matched your search

+1 -1
View File
@@ -1,5 +1,5 @@
import { ArrowRightIcon } from '@toeverything/components/icons';
import { ReactElement, useRef, useState } from 'react';
import { useRef, useState, type ReactElement } from 'react';
import { Divider } from '../divider';
import {
MuiGrow as Grow,
+9 -2
View File
@@ -35,6 +35,8 @@ export const Popper = ({
offset = [0, 5],
showArrow = false,
popperHandlerRef,
onClick,
onClickAway,
...popperProps
}: PopperProps) => {
const [anchorEl, setAnchorEl] = useState<VirtualElement>(null);
@@ -97,15 +99,20 @@ export const Popper = ({
return (
<ClickAwayListener
onClickAway={() => {
setVisible(false);
if (visibleControlledByParent) {
onClickAway?.();
} else {
setVisible(false);
}
}}
>
<Container>
{isAnchorCustom ? null : (
<div
ref={(dom: HTMLDivElement) => setAnchorEl(dom)}
onClick={() => {
onClick={e => {
if (!hasClickTrigger || visibleControlledByParent) {
onClick?.(e);
return;
}
setVisible(!visible);
@@ -62,4 +62,6 @@ export type PopperProps = {
showArrow?: boolean;
popperHandlerRef?: Ref<PopperHandler>;
onClickAway?: () => void;
} & Omit<PopperUnstyledProps, 'open' | 'ref'>;