-
Notifications
You must be signed in to change notification settings - Fork 448
Fix dropdown menu keyboard navigation traversal order potentially not matching display order #6616
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
Draft
Seercat3160
wants to merge
2
commits into
ppy:master
Choose a base branch
from
Seercat3160:seercat/dropdown-keyboard-selection-order
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
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 don't deny that there's likely a real problem here but this is a really shallow (and therefore likely incorrect) way of handling the problem.
If there's a concern that
MenuItems
may be in incorrect order after some sequence of operations, then what does it say about the correctness of the publicItems
property given the getter is implemented as follows:osu-framework/osu.Framework/Graphics/UserInterface/Dropdown.cs
Lines 65 to 78 in f91f679
Would it not follow that this property also can not follow the visual ordering?
If that is the case, what does that say about the safety of the following logic?:
osu-framework/osu.Framework/Graphics/UserInterface/Dropdown.cs
Lines 363 to 369 in f91f679
Is it not reasonable to expect to find this doing completely ridiculous things if you arrange a few move operations?
All of this is to say that this is a half-fix at best to me. Consumers clearly expect
MenuItems
andItems
to be consistent with the visual order of items. And they are right to do so, by the principle of least surprise.How one sets out to do this is up in the air, but if it were up to me, I would say that relying on the drawables to store data here is bad juju. It usually doesn't end well, especially down the line where performance starts to matter (e.g. in a year or two we suddenly want to virtualise the dropdown items at which point you can no longer rely on layout positions being there because some of the drawable items are not in the hierarchy anymore).
I would say that ideally the ordering information should be a part of the backing data model of this class, i.e. somewhere in
itemMap
or something. Or maybe you would have a separate list tracking the correct item order. Or maybe you even ditchitemMap
altogether and just have an ordered collection instead, eating the overhead from all of theContainsKey()
calls this class currently does (maybe fine, needs benchmarking on how bad it gets in real world usages).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.
When you put it like that, I agree that my changes here are a half-fix at most. I was focused on the particular thing that I had noticed and didn't see the larger cause. I was originally planning to just open an issue and link my test case, but I decided to try and see if I could fix it.
That being said, your comments here are less a review of my changes and more directed towards the existing state of this part of the codebase. Fixing that is above my level, so it might be better to migrate this to an issue.