mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-19 19:16:29 +08:00
mod(whiteboard): close tool panel when select tool
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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'>;
|
||||
|
||||
Reference in New Issue
Block a user