fix: dropdown menu entire right can be pulled down (#2568)

Co-authored-by: Whitewater <me@waterwater.moe>
(cherry picked from commit a01a3ef011)
This commit is contained in:
Hyden Liu
2023-05-29 15:03:26 +08:00
committed by himself65
parent bac5417ff1
commit 5bc7c0f69f
2 changed files with 20 additions and 9 deletions

View File

@@ -8,14 +8,14 @@ import {
import * as styles from './styles.css'; import * as styles from './styles.css';
type DropdownButtonProps = { type DropdownButtonProps = {
onClickDropDown?: MouseEventHandler<SVGSVGElement>; onClickDropDown?: MouseEventHandler<HTMLElement>;
} & ButtonHTMLAttributes<HTMLButtonElement>; } & ButtonHTMLAttributes<HTMLButtonElement>;
export const DropdownButton = forwardRef< export const DropdownButton = forwardRef<
HTMLButtonElement, HTMLButtonElement,
DropdownButtonProps DropdownButtonProps
>(({ onClickDropDown, children, ...props }, ref) => { >(({ onClickDropDown, children, ...props }, ref) => {
const handleClickDropDown: MouseEventHandler<SVGSVGElement> = e => { const handleClickDropDown: MouseEventHandler<HTMLElement> = e => {
e.stopPropagation(); e.stopPropagation();
onClickDropDown?.(e); onClickDropDown?.(e);
}; };
@@ -23,12 +23,9 @@ export const DropdownButton = forwardRef<
<button ref={ref} className={styles.dropdownBtn} {...props}> <button ref={ref} className={styles.dropdownBtn} {...props}>
<span>{children}</span> <span>{children}</span>
<span className={styles.divider} /> <span className={styles.divider} />
<ArrowDownSmallIcon <span className={styles.dropdownWrapper} onClick={handleClickDropDown}>
className={styles.icon} <ArrowDownSmallIcon className={styles.icon} width={16} height={16} />
width={16} </span>
height={16}
onClick={handleClickDropDown}
/>
</button> </button>
); );
}); });

View File

@@ -5,7 +5,8 @@ export const dropdownBtn = style({
alignItems: 'center', alignItems: 'center',
justifyContent: 'center', justifyContent: 'center',
padding: '0 10px', padding: '0 10px',
gap: '4px', // fix dropdown button click area
paddingRight: 0,
color: 'var(--affine-text-primary-color)', color: 'var(--affine-text-primary-color)',
fontWeight: 600, fontWeight: 600,
background: 'var(--affine-button-gray-color)', background: 'var(--affine-button-gray-color)',
@@ -28,6 +29,19 @@ export const divider = style({
width: '0.5px', width: '0.5px',
height: '16px', height: '16px',
background: 'var(--affine-border-color)', background: 'var(--affine-border-color)',
// fix dropdown button click area
margin: '0 4px',
marginRight: 0,
});
export const dropdownWrapper = style({
width: '100%',
height: '100%',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
paddingLeft: '4px',
paddingRight: '10px',
}); });
export const icon = style({ export const icon = style({