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

fix(ripple): don't launch ripple for fake mouse events #11997

Merged
merged 1 commit into from
Aug 27, 2018

Conversation

crisbeto
Copy link
Member

When using a screen reader the ripples can get fake mouse events when pressing space or enter. With the following changes we skip launching the ripples in these cases, in order to align the experience with the non-screen-reader.

For reference:
demo

@crisbeto crisbeto requested a review from devversion as a code owner June 30, 2018 12:06
@googlebot googlebot added the cla: yes PR author has agreed to Google's Contributor License Agreement label Jun 30, 2018
Copy link
Member

@devversion devversion left a comment

Choose a reason for hiding this comment

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

LGTM.

@@ -246,10 +246,13 @@ export class RippleRenderer {

/** Function being called whenever the trigger is being pressed using mouse. */
private onMousedown = (event: MouseEvent) => {
// Screen readers will fire fake mouse events for space/enter. Skip launching a
// ripple in this case for consistency with the non-screen-reader experience.
const isFakeMousedown = event.buttons === 0;
Copy link
Member

@devversion devversion Jun 30, 2018

Choose a reason for hiding this comment

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

We should use isFakeMousedownFromScreenReader from @angular/cdk/a11y?

Copy link
Member Author

Choose a reason for hiding this comment

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

I wanted to avoid pulling in cdk/a11y since the idea is to pull the ripples out into their own module.

Copy link
Member

@devversion devversion Jun 30, 2018

Choose a reason for hiding this comment

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

I see. I don't really think though, that this means that we should hesitate using the CDK. Even if the ripples are moved into its own module, they can still have dependencies on the CDK.

The goal is not make ripples independent from anything else. It should be just possible for developers to explicitly use @angular/material/ripple without having all the other stuff.

e.g. see @angular/material/core does have deps on the CDK, and also the ripples already use cdk/platform.

Copy link
Member Author

Choose a reason for hiding this comment

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

What I meant is that it seemed like overkill to bring in another CDK package for a one-liner method. I've switched it now.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, totally see what you mean. My reasoning is just that the CDK is being pulled by NPM anyway and with tree shaking (which is quite common used) it doesn't really matter how big the a11y package is because only the one function will be pulled in.

Copy link
Member

Choose a reason for hiding this comment

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

Not sure if I can make that decision though. Let's wait what Jeremy says on that. I'm a huge fan of consistency, and I'm worried that we'll duplicate logic which can be easily forgotten.

@crisbeto crisbeto force-pushed the ripple-fake-mouse-events branch from d57f85d to 06b7a36 Compare June 30, 2018 14:46
@crisbeto crisbeto requested a review from jelbourn as a code owner June 30, 2018 14:46
@josephperrott josephperrott added the target: patch This PR is targeted for the next patch release label Jul 2, 2018
Copy link
Member

@jelbourn jelbourn left a comment

Choose a reason for hiding this comment

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

LGTM

@jelbourn jelbourn added the action: merge The PR is ready for merge by the caretaker label Jul 9, 2018
@ngbot
Copy link

ngbot bot commented Aug 21, 2018

Hi @crisbeto! This PR has merge conflicts due to recent upstream merges.
Please help to unblock it by resolving these conflicts. Thanks!

When using a screen reader the ripples can get fake mouse events when pressing space or enter. With the following changes we skip launching the ripples in these cases, in order to align the experience with the non-screen-reader.
@crisbeto crisbeto force-pushed the ripple-fake-mouse-events branch from 06b7a36 to e0bf841 Compare August 25, 2018 17:23
@jelbourn jelbourn merged commit 4639a87 into angular:master Aug 27, 2018
@mik01aj
Copy link

mik01aj commented Aug 29, 2018

Hi @crisbeto & @jelbourn,
I was implementing a keyboard shortcuts service recently and thought it would be nice to also show the user the element they are triggering. I ended up dispatching fake events (mousedown, mouseup, click) on the button to trigger both the button action and ripples. I was able to also make it work after this PR, but it made me wonder - should I do this at all? I think the visual feedback makes it clearer for the user what is happening, but on the other hand I haven't seen apps doing this so I'm not sure.

jelbourn pushed a commit that referenced this pull request Aug 29, 2018
When using a screen reader the ripples can get fake mouse events when pressing space or enter. With the following changes we skip launching the ripples in these cases, in order to align the experience with the non-screen-reader.
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 9, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker cla: yes PR author has agreed to Google's Contributor License Agreement target: patch This PR is targeted for the next patch release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants