-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Fix MaterialState.pressed is missing when pressing button with keyboard #133558
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 MaterialState.pressed is missing when pressing button with keyboard #133558
Conversation
|
This pull request has been changed to a draft. The currently pending flutter-gold status will not be able to resolve until a new commit is pushed or the change is marked ready for review again. For more guidance, visit Writing a golden file test for Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
|
@HansMuller This is the solution I came up for #132377. It breaks some existing tests because it adds a delay before the handleTap function is called. |
|
I've asked @gspencergoog to look at this. Introducing a delay before calling handleTap does seem fraught, at least on the face of it. |
gspencergoog
left a comment
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.
So, if I understand this correctly, this is basically adding a 200ms delay when an InkWell is activated via keyboard to simulate the time between the mouse down and mouse up of a tap?
I know 200ms is arbitrary, so could it be 100ms instead? Or, even better, could it call handleTap right away, but execute the ink splash simultaneously?
The reason I ask is that I would expect that keyboard interactions with buttons would be faster than mouse interactions, and if I was implementing a virtual keyboard with InkWells, I wouldn't want it to be limited in typing speed/response time because of this delay. In a case like that, I could also imagine that keystrokes might get missed if I typed the same key rapidly, or at the least that they might build up and keep reacting long after I stopped pressing it.
626c4dc to
442c1b4
Compare
442c1b4 to
8b2e318
Compare
Yes, exactly. I think the fundamental question is what does the 'pressed' state means when an
Based on your comment, I updated the PR:
With this change it is way less risky (no existing test broken). Another solution would be to document that relying on |
|
I think this is much better that the previous version. We shouldn't just document that you can't rely on I think, ideally, if you have keyboard activation, then it should enter the You could probably do something more complex and capture all the keys that were down when the We can start with just the 100ms delay here, and if that becomes problematic (e.g. someone is writing a game and wants to know how long the key was pressed, but is using the |
gspencergoog
left a comment
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.
Co-authored-by: Greg Spencer <[email protected]>

Description
This PR fixes changes how
InkWellreacts to keyboard activation.Before: the activation started a splash and immediately terminated it which did not let time for widgets that resolve material state properties to react (visually it also mean the splash does not have time to expand).
After: the activation starts and terminates after a delay (I arbitrary choose 200ms for the moment).
Related Issue
Fixes #132377.
Tests
Adds one test.