-
Notifications
You must be signed in to change notification settings - Fork 3.8k
feat: Allow conditioned ephemeral access for drop-down & widget divs #9051
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
BenHenning
merged 2 commits into
google:rc/v12.0.0
from
BenHenning:allow-conditioned-ephemeral-access-for-drop-down-widget-divs
May 14, 2025
Merged
feat: Allow conditioned ephemeral access for drop-down & widget divs #9051
BenHenning
merged 2 commits into
google:rc/v12.0.0
from
BenHenning:allow-conditioned-ephemeral-access-for-drop-down-widget-divs
May 14, 2025
Conversation
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 unblocks fixes to 2 samples plugins.
Merged
1 task
BenHenning
commented
May 14, 2025
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.
Self-reviewed changes (mostly a spot check).
maribethb
approved these changes
May 14, 2025
…-drop-down-widget-divs
Going ahead and merging per google/blockly-samples#2521 (comment) and another double check that PR still fixes the found regressions. |
BenHenning
added a commit
to google/blockly-samples
that referenced
this pull request
May 15, 2025
## The basics - [x] I [validated my changes](https://developers.google.com/blockly/guides/contribute/samples#making_and_verifying_a_change) ## The details ### Resolves Fixes #2514 Fixes #2515 ### Proposed Changes This updates the custom field implementations for `field-sldier` and `field-angle` to use new functionality introduced in google/blockly#9051. ### Reason for Changes The regressions reported in #2514 and #2515 were introduced due to the custom fields introducing a scenario where _both_ widget and drop-down divs attempted to take ephemeral focus. This isn't allowed currently as core's `FocusManager` has no tie breaking functionality for ephemeral focus, so the second attempt to request it throws a runtime failure. The functionality introduced in google/blockly#9051 allows the custom fields to, through `FieldInput`, disable the automatic ephemeral focus management for `FieldInput`'s inline editor (which uses widget div) so that the custom fields' drop-down div editors can properly take focus, instead. ### Test Coverage This has been manually tested locally. Automated tests are, unfortunately, non-trivial here since verifying focus-related behavior (at least through user interactions) requires a working DOM and is very tricky to make work with Node.js. These are tests that would likely be better suited via webdriver, instead. #2527 has been filed to track this work. ### Documentation No additional documentation is needed here. ### Additional Information This requires google/blockly#9051 in order to work.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
The basics
The details
Resolves
Needed for fixing google/blockly-samples#2514 and google/blockly-samples#2515.
Proposed Changes
Update
FieldInput
along with drop-down and widget divs to support disabling the automatic ephemeral focus functionality.Reason for Changes
As mentioned in google/blockly-samples#2514 (comment) both google/blockly-samples#2514 and google/blockly-samples#2515 were caused by the custom fields leading to both drop-down and widget divs simultaneously taking ephemeral focus (and that's not currently allowed by
FocusManager
). This change updates both widget and drop-down divs with optional parameters to conditionally disable automatic ephemeral focus so thatFieldInput
can, in turn, be customized with disabling automatic ephemeral focus for its inline editor. Being able to disable ephemeral focus forFieldInput
allows the custom fields' own drop-down divs to take and manage ephemeral focus, instead, avoiding the duplicate scenario that led to the runtime failure.Note that the drop-down div change in this PR is completely optional, but it's added for consistency and to avoid future scenarios of breakage when trying to use both divs together (as a fix is required in Core without monkeypatching).
It's worth noting that there could be a possibility for a more 'proper' fix in
FocusManager
by allowing multiple calls totakeEphemeralFocus
, but it's unclear exactly how to solve this consistently (which is why it results in a hard failure today). The main issue is that the current focused node can change from underneath the manager (due to DOM focus changes), and the current focused element may also change. It's not clear if the first, last, or some other call totakeEphemeralFocus
should take precedent or which node to return focus once ephemeral focus ends (in cases with multiple subsequent calls).Test Coverage
No new tests were added, though common field cases were tested manually in core's simple playground and in the plugin-specific playgrounds (per the original regressions). The keyboard navigation plugin test environment was also verified to ensure that this didn't alter any existing behavior (it should be a no-op except for the two custom field plugins).
Automated tests would be nice to add for all three classes, perhaps as part of #8915.
Documentation
The code documentation changes here should be sufficient.
Additional Information
These changes are being done directly to ease solving the above samples issues. See google/blockly-samples#2521 for the follow-up fixes to samples.