8000 fix: Improve missing node resiliency by BenHenning · Pull Request #8997 · google/blockly · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

fix: Improve missing node resiliency #8997

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

Merged

Conversation

BenHenning
Copy link
Contributor
@BenHenning BenHenning commented May 6, 2025

The basics

The details

Resolves

Fixes #8994

Proposed Changes

This removes an error that was previously thrown by FocusManager when attempting to focus an invalid node (such as one that's been removed from its parent).

Reason for Changes

#8994 (comment) goes into more detail. While this error did cover legitimately wrong cases to try and focus things (and helped to catch some real problems), fixing this 'properly' may become a leaky boat problem where we have to track down every possible asynchronous scenario that could produce such a case. One class of this is ephemeral focus which had robustness improvements itself in #8981 that, by effect, caused this issue in the first place. Holistically fixing this with enforced API contracts alone isn't simple due to the nature of how these components interact.

This change ensures that there's a sane default to fall back on if an invalid node is passed in. Note that FocusManager was designed specifically to disallow defocusing a node (since fallbacks can get messy and introduce unpredictable user experiences), and this sort of allows that now. However, this seems like a reasonable approach as it defaults to the behavior when focusing a tree explicitly which allows the tree to fallback to a more suitable default (such as the first item to select in the toolbox for that particular tree). In many cases this will default back to the tree's root node (such as the workspace root group) since sometimes the removed node is still the "last focused node" of the tree (and is considered valid for the purpose of determining a fallback; tree implementations could further specialize by checking whether that node is still valid).

Test Coverage

Some new tests were added to cover this case, but more may be useful to add as part of #8910.

Documentation

No documentation needs to be added or updated as part of this (beyond code documentation changes).

Additional Information

This original issue was found by @RoboErikG when testing #8995. I also verified this against the keyboard navigation plugin repository.

This adds better resiliency in FocusManager when trying to focus nodes
that are no longer attached to their parents (which can happen in some
asynchronous cases).
@BenHenning BenHenning requested a review from a team as a code owner May 6, 2025 19:47
@BenHenning BenHenning requested a review from gonfunko May 6, 2025 19:47
@github-actions github-actions bot added PR: fix Fixes a bug and removed PR: fix Fixes a bug labels May 6, 2025
BenHenning added 2 commits May 6, 2025 19:48
This helps to be clear on another case now possible for
IFocusableTree.getRestoredFocusableNode.
Copy link
Contributor Author
@BenHenning BenHenning left a comment

Choose a reason for hiding this comment

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

Self-reviewed changes (needed a couple of follow-up fixes).

@BenHenning
Copy link
Contributor Author

@rachel-fenichel also assigning to you in case you have time to review this before @gonfunko.

@BenHenning BenHenning linked an issue May 6, 2025 that may be closed by this pull request
1 task
@BenHenning BenHenning merged commit a3b3ea7 into google:rc/v12.0.0 May 6, 2025
7 checks passed
@BenHenning BenHenning deleted the improve-missing-node-resiliency branch May 6, 2025 19:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR: fix Fixes a bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Deleting a variable throws an exception
3 participants
0