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
[Tooltip] Implement fix for MouseOver event not firing when cursor enters after leaving a disabled element #1783
Conversation
👋 Thanks for opening your first pull request. A contributor should give feedback soon. If you haven’t already, please check out the contributing guidelines. You can also join #polaris on the Shopify Partners Slack. |
b47a915
to
f01c0d8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I asked @dpersing to take a look at this since it has accessibility implications. Keyboard and screen reader users already won’t be able to read the tooltip, so I’m not sure this change makes anything worse. I do wonder if this might open up tooltips to be used in more situations where maybe they shouldn’t be…
Hi @rexmac! Could you include the Playground code you show in the gifs so we can manually text your example? There should be a section of the PR template for it:
|
@dpersing Added. 😃 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dpersing Thanks! Approved based on your input
f01c0d8
to
eb75f62
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Everything looks good 🎉 🎩
it('renders on mouseEnter', () => { | ||
wrapperComponent.simulate('mouseEnter'); | ||
it('renders on mouseOver', () => { | ||
wrapperComponent.simulate('mouseOver'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need the extra simulate and expect?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just saw the commit message was for codecov. Maybe we should break the assertion into its own test and expect mouseOver is called once?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ya, I was testing to see if it would satisfy codecov, which it did. It definitely feels hacky, but I'm not sure how else to satisfy codecov. I think ideally we'd assert that handleMouseEnter
is only called once, but it's a private method.
Maybe we should break the assertion into its own test and expect mouseOver is called once?
I don't follow. Can you elaborate?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ignore that, I was under the assumption we exposed a mouseEnter handler 😅 These changes may give you codecov
private handleMouseEnter = () => {
this.mouseEntered = true;
this.setState({active: true});
};
private handleMouseEnterFix = () => {
!this.mouseEntered && this.handleMouseEnter();
};
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! I'll give that a shot. 👍
6fc8816
to
b91dbe8
Compare
b91dbe8
to
de9020a
Compare
de9020a
to
a017ab4
Compare
… leaving a disabled element
a017ab4
to
c4d432a
Compare
🎉 Thanks for your contribution to Polaris React! |
WHY are these changes introduced?
Fixes #1782.
MouseEnter events are not triggered when cursor enters from a disabled element.
WHAT is this pull request doing?
Uses MouseOver with a "mouseEntered" boolean flag rather than MouseEnter.
Before
After
Copy-paste this code in
playground/Playground.tsx
:🎩 checklist
README.md
with documentation changes