Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bugfix]: fix mouse-events don't fire on disabled element pop #1655

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions packages/zent/__tests__/popover.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,13 +126,13 @@ describe('Popover', () => {
expect(wrapper.find('PurePortal').length).toBe(0);

// 快速进入又快速离开
wrapper.find('button').simulate('mouseenter');
wrapper.find('button').simulate('pointerenter');
expect(wrapper.find('PurePortal').length).toBe(0);
wrapper.find('button').simulate('mouseleave');
wrapper.find('button').simulate('pointerleave');
expect(wrapper.find('PurePortal').length).toBe(0);

// hover 直到popup,然后window监听mousemove,判断是否离开。
simulateWithTimers(wrapper.find('button'), 'mouseenter');
simulateWithTimers(wrapper.find('button'), 'pointerenter');
wrapper.update();
expect(wrapper.find('PurePortal').length).toBe(1);
const fakeEvent = new MouseEvent('mousemove');
Expand Down Expand Up @@ -434,7 +434,7 @@ describe('Popover', () => {
</Popover>
);

simulateWithTimers(wrapper.find('button'), 'mouseenter');
simulateWithTimers(wrapper.find('button'), 'pointerenter');
wrapper.update();
expect(wrapper.find('PurePortal').length).toBe(1);

Expand Down
4 changes: 1 addition & 3 deletions packages/zent/src/grid/SelectionCheckbox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,7 @@ class SelectionCheckbox extends PureComponent<
const { checked } = this.state;
return reason && disabled ? (
<Pop content={reason} trigger="hover" position="top-left" centerArrow>
<span>
<Checkbox onChange={onChange} checked={checked} disabled={disabled} />
</span>
<Checkbox onChange={onChange} checked={checked} disabled={disabled} />
</Pop>
) : (
<Checkbox onChange={onChange} checked={checked} disabled={disabled} />
Expand Down
4 changes: 1 addition & 3 deletions packages/zent/src/grid/SelectionRadio.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,7 @@ class SelectionCheckbox extends PureComponent<
const { checked } = this.state;
return reason && disabled ? (
<Pop content={reason} trigger="hover" position="top-left" centerArrow>
<span>
<Radio onChange={onChange} checked={checked} disabled={disabled} />
</span>
<Radio onChange={onChange} checked={checked} disabled={disabled} />
</Pop>
) : (
<Radio onChange={onChange} checked={checked} disabled={disabled} />
Expand Down
8 changes: 4 additions & 4 deletions packages/zent/src/popover/trigger/HoverTrigger.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -110,20 +110,20 @@ export function PopoverHoverTrigger<
});
} else if (isElement(children)) {
child = cloneElement(children, {
onMouseEnter(...args: any[]) {
onPointerEnter(...args: any[]) {
children.props.onMouseEnter?.(...args);
visible$.next(true);
},
onMouseLeave(...args: any[]) {
onPointerLeave(...args: any[]) {
children.props.onMouseLeave?.(...args);
visible$.next(false);
},
});
} else {
child = (
<span
onMouseEnter={() => visible$.next(true)}
onMouseLeave={() => visible$.next(false)}
onPointerEnter={() => visible$.next(true)}
onPointerLeave={() => visible$.next(false)}
>
{children}
</span>
Expand Down