-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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 nav-to-nearest mixin when there are no ancestors #6198
Merged
Merged
Changes from all commits
Commits
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 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 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 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
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.
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.
Hey 👋
Just a little observation/suggestion here. I'm not even sure this is possible as I don't know how else you are using
utils.ancestorKeysForKey
.Theoretically you could have this bug happening anywhere you are using
utils.ancestorKeysForKey
just it's not been noticed it yet, but you've only added theancestors
truthy check here.Ideally, (although I'm not sure if its possible, and would be a bigger/riskier change). If
utils.ancestorKeysForKey
returned an empty array instead ofnull
where there are no 'ancestorKeys', then yourwhile
here would still not run ([].pop() === undefined
)I just had a quick look to see where else you are using this method:
In
namespace-picker
you switch anull
result back to an empty array anyway, and inkey-value-header
you do another truthy check on the return value which you could switch to alength
check (Q: How many ancestors are there for this key? A: Zero)So this is possible I 'think' (as long as my search picked up all places you are using this) and it's probably not that risky to do either and doing this would prevent any further bugs like this slipping in in the future.
TLDR; is You'd be changing it so the method would always return an array (no alarms and no surprises), not 'mostly an array, but sometimes
null
'.Anyway, I just had a peek here whilst drinking my morning tea, thought you might like that ^ - no matter if not.
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.
Thanks for pointing this out - been waayyy too long since I've looked at the util code and took a wider view of its usage. I made the necessary changes / cleanup in #6205