-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Expose the currently available semantic scroll actions #11286
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
Conversation
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.
nit: no braces
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.
Since this makes the earlier work pointless, maybe put all the earlier work into the else branch of this if block?
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.
It does not make the previous work pointless. We should only expose an action if there is a handler that can handle it (previous work) and if it is valid (the work in the if).
If there - for whatever reason - is no handler, we will blow up when executing the gesture....
|
This is great. Test? |
|
|
||
| // If a set of validActions has been provided only expose those. | ||
| if (validActions != null) | ||
| actions = actions.where((SemanticsAction action) => validActions.contains(action)).toList(); |
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.
this is O(N^2). Since validActions is only used for this, maybe it should be a Set instead of a List?
Or maybe it should just be a pair of booleans ("can scroll backwards" and "can scroll forwards")? Then you could just check the booleans when adding the actions?
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 wasn't too worried about that as validActions is guaranteed to be very small. Having said that, I refactored it to a Set, which gives us O(1) for contains. Happy to optimize further if this turns out to be an actual performance bottleneck.
Fixes #1675.