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

[BottomNavigationAction] Fix onClick doublefire in Firefox #28242

Conversation

EliasJorgensen
Copy link
Contributor

@EliasJorgensen EliasJorgensen commented Sep 9, 2021

This PR reverts #27690, fixes #27664 and closes #22368, by increasing the timeout used on touch events, to determine whether the onClick event should be fired or not.
BottomNavigationAction now uses the DELAY_RIPPLE timeout, imported from TouchRipple.js.

The investigation for the regression can be found here #22368 (comment).

@mui-pr-bot
Copy link

mui-pr-bot commented Sep 9, 2021

Details of bundle changes (experimental)

@material-ui/core: parsed: +Infinity% , gzip: +Infinity%
@material-ui/lab: parsed: +Infinity% , gzip: +Infinity%
@material-ui/styles: parsed: +Infinity% , gzip: +Infinity%
@material-ui/private-theming: parsed: +Infinity% , gzip: +Infinity%
@material-ui/system: parsed: +Infinity% , gzip: +Infinity%
@material-ui/unstyled: parsed: +Infinity% , gzip: +Infinity%
@material-ui/utils: parsed: +Infinity% , gzip: +Infinity%

Generated by 🚫 dangerJS against a81d931

@EliasJorgensen
Copy link
Contributor Author

It seems like the codesandbox check is stuck? It's been running for 40 minutes now, other builds only go for about 4-5 minutes? 🤔

Copy link
Member

@eps1lon eps1lon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's still not clear why a BottomNavigationAction should behave differently than any other button or button-like element. We need to clarify this in the issue before forking the behavior since that's highly confusing the developers and users alike.

@eps1lon eps1lon added the on hold There is a blocker, we need to wait label Sep 10, 2021
Comment on lines 95 to 241
target: container,
clientX: 42,
clientY: 42,
}),
],
});

fireEvent.touchEnd(container.firstChild, {
changedTouches: [
new Touch({
identifier: 1,
target: container,
clientX: 42,
clientY: 42,
}),
],
});

getByRole('button').click();

clock.tick(100);

expect(handleClick.callCount).to.equal(1);
});

it('should not fire onClick if swiping', () => {
const handleClick = spy();

// Need disableTouchRipple to avoid ripple missing act (async setState after touchEnd)
const { container } = render(
<BottomNavigationAction onClick={handleClick} disableTouchRipple />,
);

fireEvent.touchStart(container.firstChild, {
touches: [
new Touch({
identifier: 1,
target: container,
clientX: 42,
clientY: 42,
}),
],
});

fireEvent.touchEnd(container.firstChild, {
changedTouches: [
new Touch({
identifier: 1,
target: container,
clientX: 84,
clientY: 84,
}),
],
});

clock.tick(10);

expect(handleClick.callCount).to.equal(0);
});

it('should forward onTouchStart and onTouchEnd events', () => {
const handleTouchStart = spy();
const handleTouchEnd = spy();

// Need disableTouchRipple to avoid ripple missing act (async setState after touchEnd).
const { container } = render(
<BottomNavigationAction
onTouchStart={handleTouchStart}
onTouchEnd={handleTouchEnd}
disableTouchRipple
/>,
);

fireEvent.touchStart(container.firstChild, {
touches: [
new Touch({
identifier: 1,
target: container,
clientX: 42,
clientY: 42,
}),
],
});

expect(handleTouchStart.callCount).to.be.equals(1);

fireEvent.touchEnd(container.firstChild, {
changedTouches: [
new Touch({
identifier: 1,
target: container,
clientX: 84,
clientY: 84,
}),
],
});

expect(handleTouchEnd.callCount).to.be.equals(1);
});
});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How did you come up with this event order? A codesandbox to verify that this is actually happening, is important. For example, it's a bit odd that a child is the target of the touch event but the touch itself is the parent.

Copy link
Contributor Author

@EliasJorgensen EliasJorgensen Sep 10, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not remember, the PR for this was accepted by @oliviertassinari a year ago, in #22524.
The only new code in this PR, is the code in commit 6082ceb.

@EliasJorgensen
Copy link
Contributor Author

It's still not clear why a BottomNavigationAction should behave differently than any other button or button-like element. We need to clarify this in the issue before forking the behavior since that's highly confusing the developers and users alike.

@eps1lon Honestly it's pretty frustrating that you disagree internally, when interacting outwards with contributers who want to help out. @oliviertassinari clearly asked me to work on this here, so that you now continue to question it's entire existence (despite a core MUI member asking me to fix that regression) is a pretty confusing choice of communication.

@eps1lon eps1lon changed the base branch from next to master September 14, 2021 09:09
@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label Nov 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
on hold There is a blocker, we need to wait PR: out-of-date The pull request has merge conflicts and can't be merged
Projects
None yet
3 participants