-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Get active element within the iframe when restoring focus #68060
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
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
|
Size Change: +10 B (0%) Total Size: 1.84 MB
ℹ️ View Unchanged
|
| if ( onSelect && typeof onSelect === 'function' ) { | ||
| onSelect( ...args ); | ||
| } | ||
| inserterButtonRef.current?.focus(); |
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 file is undoing work from https://github.com/WordPress/gutenberg/pull/64877/files#diff-4cdcf916fb8cf5f88b98cd9e95ab532d90369cd768334f7896720a2b85c018bbR37 which fixed moving focus to the appender, but did it without addressing the root issue.
ajlende
left a comment
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 had the thought that this could be recursive for nested iframes, but we probably don't need that for now.
Just had one suggestion for cleaner, more robust code.
Co-authored-by: Alex Lende <[email protected]>
|
Flaky tests detected in 0c834eb. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/12398561057
|
|
Thanks for the fix! Would it be worth backporting this PR to WP 6.7.2? Because #67809 is an issue that first appeared in WP 6.7. |
…ocus (#68060) Co-authored-by: Alex Lende <[email protected]>
I think so, provided no bugs pop up as a result of it :) |
…ocus (#68060) Co-authored-by: Alex Lende <[email protected]>
|
@jeryj Have you seen any bugs since this shipped in Gutenebrg 20.0 that would make you 2nd guess backporting for WP 6.7.2? |
|
I have not seen any, however, I was also on vacation and then working on other projects. So, I have not really used the editor much to test. |
…ocus (#68060) (#68200) Co-authored-by: jeryj <[email protected]> Co-authored-by: t-hamano <[email protected]> Co-authored-by: aaronjorbin <[email protected]>
|
This fix was backported to WP 6.7.2 as #68200. |
Syncs Editor packages for WordPress 6.7.2 RC1. Includes the following PRs: - PostTitle: exit early when post type doesn't support titles WordPress/gutenberg#67086 - Patterns: receive intermediate responses while unbound request is resolving WordPress/gutenberg#66713 WordPress/gutenberg#67244 - Fix: Show Meta Boxes at the bottom of the screen regardless of the current rendering mode WordPress/gutenberg#66508 - [6.7] Zoom in/out to correct location WordPress/gutenberg#66618 - Composite: Restore Hover and Typeahead functionality - Backport to 6.7.2 WordPress/gutenberg#67258 - Interactivity API: fix property modification backport to 6.7.2 WordPress/gutenberg#67259 - Fix unexpected unlock control in block toolbar in non-default editing mode WordPress/gutenberg#67121 - [WP 6.7] Fix meta boxes saving when they’re not present WordPress/gutenberg#67503 - iAPI: Fix the logic path that merges plain objects - Backport to 6.7.2 WordPress/gutenberg#68713 - e2e:fix WP Editor Meta Boxes test WordPress/gutenberg#68886 - Keep meta boxes unsplit from content in device preview https://github.com/WordPress/gutenberg/pull/68902s - useFocusReturn: Get active element within the iframe when restoring focus WordPress/gutenberg#68060 WordPress/gutenberg#68200 Co-authored-by: Aki Hamano <[email protected]> Co-authored-by: DAreRodz <[email protected]> Co-authored-by: David <[email protected]> Co-authored-by: Ella <[email protected]> Co-authored-by: Jarda Snajdr <[email protected]> Co-authored-by: Lena Morita <[email protected]> Co-authored-by: Mamaduka <[email protected]> Co-authored-by: Mayank-Tripathi32 <[email protected]> Co-authored-by: PARTHVATALIYA <[email protected]> Co-authored-by: Riad Benguella <[email protected]> Co-authored-by: SantosGuillamot <[email protected]> Co-authored-by: Tropicalista <[email protected]> Co-authored-by: aaronjorbin <[email protected]> Co-authored-by: ajlende <[email protected]> Co-authored-by: cbravobernal <[email protected]> Co-authored-by: danielpost <[email protected]> Co-authored-by: dcalhoun <[email protected]> Co-authored-by: ellatrix <[email protected]> Co-authored-by: fabiankaegy <[email protected]> Co-authored-by: getdave <[email protected]> Co-authored-by: gziolo <[email protected]> Co-authored-by: im3dabasia <[email protected]> Co-authored-by: jameskoster <[email protected]> Co-authored-by: jeryj <[email protected]> Co-authored-by: jsnajdr <[email protected]> Co-authored-by: mcsf <[email protected]> Co-authored-by: michalczaplinski <[email protected]> Co-authored-by: mirka <[email protected]> Co-authored-by: mt8 <[email protected]> Co-authored-by: ndiego <[email protected]> Co-authored-by: sathyapulse <[email protected]> Co-authored-by: sirreal <[email protected]> Co-authored-by: stokesman <[email protected]> Co-authored-by: t-hamano <[email protected]> Co-authored-by: tyxla <[email protected]> Co-authored-by: youknowriad <[email protected]>
Syncs Editor packages for WordPress 6.7.2 RC1. Includes the following PRs: - PostTitle: exit early when post type doesn't support titles WordPress/gutenberg#67086 - Patterns: receive intermediate responses while unbound request is resolving WordPress/gutenberg#66713 WordPress/gutenberg#67244 - Fix: Show Meta Boxes at the bottom of the screen regardless of the current rendering mode WordPress/gutenberg#66508 - [6.7] Zoom in/out to correct location WordPress/gutenberg#66618 - Composite: Restore Hover and Typeahead functionality - Backport to 6.7.2 WordPress/gutenberg#67258 - Interactivity API: fix property modification backport to 6.7.2 WordPress/gutenberg#67259 - Fix unexpected unlock control in block toolbar in non-default editing mode WordPress/gutenberg#67121 - [WP 6.7] Fix meta boxes saving when they’re not present WordPress/gutenberg#67503 - iAPI: Fix the logic path that merges plain objects - Backport to 6.7.2 WordPress/gutenberg#68713 - e2e:fix WP Editor Meta Boxes test WordPress/gutenberg#68886 - Keep meta boxes unsplit from content in device preview https://github.com/WordPress/gutenberg/pull/68902s - useFocusReturn: Get active element within the iframe when restoring focus WordPress/gutenberg#68060 WordPress/gutenberg#68200 Co-authored-by: Aki Hamano <[email protected]> Co-authored-by: DAreRodz <[email protected]> Co-authored-by: David <[email protected]> Co-authored-by: Ella <[email protected]> Co-authored-by: Jarda Snajdr <[email protected]> Co-authored-by: Lena Morita <[email protected]> Co-authored-by: Mamaduka <[email protected]> Co-authored-by: Mayank-Tripathi32 <[email protected]> Co-authored-by: PARTHVATALIYA <[email protected]> Co-authored-by: Riad Benguella <[email protected]> Co-authored-by: SantosGuillamot <[email protected]> Co-authored-by: Tropicalista <[email protected]> Co-authored-by: aaronjorbin <[email protected]> Co-authored-by: ajlende <[email protected]> Co-authored-by: cbravobernal <[email protected]> Co-authored-by: danielpost <[email protected]> Co-authored-by: dcalhoun <[email protected]> Co-authored-by: ellatrix <[email protected]> Co-authored-by: fabiankaegy <[email protected]> Co-authored-by: getdave <[email protected]> Co-authored-by: gziolo <[email protected]> Co-authored-by: im3dabasia <[email protected]> Co-authored-by: jameskoster <[email protected]> Co-authored-by: jeryj <[email protected]> Co-authored-by: jsnajdr <[email protected]> Co-authored-by: mcsf <[email protected]> Co-authored-by: michalczaplinski <[email protected]> Co-authored-by: mirka <[email protected]> Co-authored-by: mt8 <[email protected]> Co-authored-by: ndiego <[email protected]> Co-authored-by: sathyapulse <[email protected]> Co-authored-by: sirreal <[email protected]> Co-authored-by: stokesman <[email protected]> Co-authored-by: t-hamano <[email protected]> Co-authored-by: tyxla <[email protected]> Co-authored-by: youknowriad <[email protected]>
Syncs Editor packages for WordPress 6.7.2 RC1. Includes the following PRs: - PostTitle: exit early when post type doesn't support titles WordPress/gutenberg#67086 - Patterns: receive intermediate responses while unbound request is resolving WordPress/gutenberg#66713 WordPress/gutenberg#67244 - Fix: Show Meta Boxes at the bottom of the screen regardless of the current rendering mode WordPress/gutenberg#66508 - [6.7] Zoom in/out to correct location WordPress/gutenberg#66618 - Composite: Restore Hover and Typeahead functionality - Backport to 6.7.2 WordPress/gutenberg#67258 - Interactivity API: fix property modification backport to 6.7.2 WordPress/gutenberg#67259 - Fix unexpected unlock control in block toolbar in non-default editing mode WordPress/gutenberg#67121 - [WP 6.7] Fix meta boxes saving when they’re not present WordPress/gutenberg#67503 - iAPI: Fix the logic path that merges plain objects - Backport to 6.7.2 WordPress/gutenberg#68713 - e2e:fix WP Editor Meta Boxes test WordPress/gutenberg#68886 - Keep meta boxes unsplit from content in device preview https://github.com/WordPress/gutenberg/pull/68902s - useFocusReturn: Get active element within the iframe when restoring focus WordPress/gutenberg#68060 WordPress/gutenberg#68200 Reviewed-by audrasjb. Props 0mirka00, ajlende, cbravobernal, czapla, danielpost, darerodz, dpcalhoun, ellatrix, fabiankaegy, get_dave, gziolo, im3dabasia1, jameskoster, jeryj, jonsurrell, jorbin, jsnajdr, mamaduka, mayanktripathi32, mcsf, mt8biz, ndiego, parthvataliya, presstoke, santosguillamot, sathyapulse, tropicalista, tyxla, wildworks, youknowriad. Fixes #62889. git-svn-id: https://develop.svn.wordpress.org/branches/6.7@59762 602fd350-edb4-49c9-b593-d223f7449a82
Syncs Editor packages for WordPress 6.7.2 RC1. Includes the following PRs: - PostTitle: exit early when post type doesn't support titles WordPress/gutenberg#67086 - Patterns: receive intermediate responses while unbound request is resolving WordPress/gutenberg#66713 WordPress/gutenberg#67244 - Fix: Show Meta Boxes at the bottom of the screen regardless of the current rendering mode WordPress/gutenberg#66508 - [6.7] Zoom in/out to correct location WordPress/gutenberg#66618 - Composite: Restore Hover and Typeahead functionality - Backport to 6.7.2 WordPress/gutenberg#67258 - Interactivity API: fix property modification backport to 6.7.2 WordPress/gutenberg#67259 - Fix unexpected unlock control in block toolbar in non-default editing mode WordPress/gutenberg#67121 - [WP 6.7] Fix meta boxes saving when they’re not present WordPress/gutenberg#67503 - iAPI: Fix the logic path that merges plain objects - Backport to 6.7.2 WordPress/gutenberg#68713 - e2e:fix WP Editor Meta Boxes test WordPress/gutenberg#68886 - Keep meta boxes unsplit from content in device preview https://github.com/WordPress/gutenberg/pull/68902s - useFocusReturn: Get active element within the iframe when restoring focus WordPress/gutenberg#68060 WordPress/gutenberg#68200 Reviewed-by audrasjb. Props 0mirka00, ajlende, cbravobernal, czapla, danielpost, darerodz, dpcalhoun, ellatrix, fabiankaegy, get_dave, gziolo, im3dabasia1, jameskoster, jeryj, jonsurrell, jorbin, jsnajdr, mamaduka, mayanktripathi32, mcsf, mt8biz, ndiego, parthvataliya, presstoke, santosguillamot, sathyapulse, tropicalista, tyxla, wildworks, youknowriad. Fixes #62889. Built from https://develop.svn.wordpress.org/branches/6.7@59762 git-svn-id: http://core.svn.wordpress.org/branches/6.7@59104 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Fixes #67809
What?
useFocusReturndoesn't work for items within the editor canvas iframe. Focus is sent to theiframecanvas instead of the active element within it. This PR allows for focus to get restored to the active element within the canvas.Why?
This root focus loss issue has caused a lot of fragile hotfixes. After this is merged, we can remove them. Here's a list of ones I know about:
How?
The
useFocusReturnhook stores theactiveElementasfocusedBeforeMount.current, and then when popover/modal/etc closes, it returns focus to thefocusedBeforeMount.current.This works well unless the
activeElementis within aniframe(like the editor canvas). If the element is within aniframe, then thefocusedBeforeMount.currentis set as the iframe itself, not theactiveElementwithin theiframe.This PR checks to see if the
activeElementis aniframeand if theiframehas anactiveElementitself. If so, it sets theactiveElementwithin theiframeas thefocusedBeforeMount.current.Testing Instructions
Testing Instructions for Keyboard
Screenshots or screencast