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