mirror of
https://gitee.com/baidu/amis.git
synced 2024-12-02 03:58:07 +08:00
chore: 修复 DropDownButton 在 hover 状态下不好点击按钮的问题 (#3690)
This commit is contained in:
parent
6dcf81706d
commit
42c658178e
@ -696,7 +696,7 @@ export const examples = [
|
|||||||
{
|
{
|
||||||
label: 'APP 多页应用',
|
label: 'APP 多页应用',
|
||||||
icon: 'fa fa-cubes',
|
icon: 'fa fa-cubes',
|
||||||
path: '/app/',
|
path: '/examples/app/',
|
||||||
component: () => {
|
component: () => {
|
||||||
// 如果在 gh-pages 里面
|
// 如果在 gh-pages 里面
|
||||||
if (/^\/amis/.test(window.location.pathname)) {
|
if (/^\/amis/.test(window.location.pathname)) {
|
||||||
|
@ -147,12 +147,14 @@ export default class DropDownButton extends React.Component<
|
|||||||
};
|
};
|
||||||
|
|
||||||
target: any;
|
target: any;
|
||||||
|
timer: ReturnType<typeof setTimeout>;
|
||||||
constructor(props: DropDownButtonProps) {
|
constructor(props: DropDownButtonProps) {
|
||||||
super(props);
|
super(props);
|
||||||
|
|
||||||
this.open = this.open.bind(this);
|
this.open = this.open.bind(this);
|
||||||
this.close = this.close.bind(this);
|
this.close = this.close.bind(this);
|
||||||
this.toogle = this.toogle.bind(this);
|
this.toogle = this.toogle.bind(this);
|
||||||
|
this.keepOpen = this.keepOpen.bind(this);
|
||||||
this.domRef = this.domRef.bind(this);
|
this.domRef = this.domRef.bind(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -183,9 +185,17 @@ export default class DropDownButton extends React.Component<
|
|||||||
}
|
}
|
||||||
|
|
||||||
close() {
|
close() {
|
||||||
this.setState({
|
this.timer = setTimeout(() => {
|
||||||
isOpened: false
|
this.setState({
|
||||||
});
|
isOpened: false
|
||||||
|
});
|
||||||
|
}, 200);
|
||||||
|
}
|
||||||
|
|
||||||
|
keepOpen() {
|
||||||
|
if (this.timer) {
|
||||||
|
clearTimeout(this.timer);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
renderButton(
|
renderButton(
|
||||||
@ -260,6 +270,7 @@ export default class DropDownButton extends React.Component<
|
|||||||
menuClassName
|
menuClassName
|
||||||
)}
|
)}
|
||||||
onClick={closeOnClick ? this.close : noop}
|
onClick={closeOnClick ? this.close : noop}
|
||||||
|
onMouseEnter={this.keepOpen}
|
||||||
ref={ref}
|
ref={ref}
|
||||||
>
|
>
|
||||||
{children
|
{children
|
||||||
|
Loading…
Reference in New Issue
Block a user