mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-18 14:56:59 +08:00
fix: menu item click area (#3051)
This commit is contained in:
@@ -44,6 +44,10 @@ export const content = style({
|
|||||||
flex: 1,
|
flex: 1,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
export const postfix = style({
|
||||||
|
justifySelf: 'flex-end',
|
||||||
|
});
|
||||||
|
|
||||||
export const icon = style({
|
export const icon = style({
|
||||||
color: 'var(--affine-icon-color)',
|
color: 'var(--affine-icon-color)',
|
||||||
fontSize: '20px',
|
fontSize: '20px',
|
||||||
|
|||||||
@@ -19,6 +19,10 @@ export interface MenuLinkItemProps
|
|||||||
extends MenuItemProps,
|
extends MenuItemProps,
|
||||||
Pick<LinkProps, 'href'> {}
|
Pick<LinkProps, 'href'> {}
|
||||||
|
|
||||||
|
const stopPropagation: React.MouseEventHandler = e => {
|
||||||
|
e.stopPropagation();
|
||||||
|
};
|
||||||
|
|
||||||
export const MenuItem = React.forwardRef<HTMLDivElement, MenuItemProps>(
|
export const MenuItem = React.forwardRef<HTMLDivElement, MenuItemProps>(
|
||||||
(
|
(
|
||||||
{
|
{
|
||||||
@@ -44,6 +48,7 @@ export const MenuItem = React.forwardRef<HTMLDivElement, MenuItemProps>(
|
|||||||
<div
|
<div
|
||||||
ref={ref}
|
ref={ref}
|
||||||
{...props}
|
{...props}
|
||||||
|
onClick={onClick}
|
||||||
className={clsx([styles.root, props.className])}
|
className={clsx([styles.root, props.className])}
|
||||||
data-active={active}
|
data-active={active}
|
||||||
data-disabled={disabled}
|
data-disabled={disabled}
|
||||||
@@ -69,15 +74,16 @@ export const MenuItem = React.forwardRef<HTMLDivElement, MenuItemProps>(
|
|||||||
)}
|
)}
|
||||||
{React.cloneElement(icon, {
|
{React.cloneElement(icon, {
|
||||||
className: clsx([styles.icon, icon.props.className]),
|
className: clsx([styles.icon, icon.props.className]),
|
||||||
onClick: onClick,
|
|
||||||
})}
|
})}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<div onClick={onClick} className={styles.content}>
|
<div className={styles.content}>{children}</div>
|
||||||
{children}
|
{postfix ? (
|
||||||
</div>
|
<div className={styles.postfix} onClick={stopPropagation}>
|
||||||
{postfix}
|
{postfix}
|
||||||
|
</div>
|
||||||
|
) : null}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user