Skip to content

Post Template Panel: Preserve parent modal when closing template creation dialog#69724

Merged
Mamaduka merged 1 commit into
WordPress:trunkfrom
yogeshbhutkar:fix-69722/focus-post-template-panel
Mar 27, 2025
Merged

Post Template Panel: Preserve parent modal when closing template creation dialog#69724
Mamaduka merged 1 commit into
WordPress:trunkfrom
yogeshbhutkar:fix-69722/focus-post-template-panel

Conversation

@yogeshbhutkar

@yogeshbhutkar yogeshbhutkar commented Mar 27, 2025

Copy link
Copy Markdown
Contributor

What?

Closes #69722

This PR fixes a focus loss issue when the template creation dialog is closed via the Escape key or the Cancel button.

Why?

The issue occurs because, upon closing the modal, focus should return to its trigger button. However, closing the modal also closes the parent dropdown containing the trigger, leaving no element to receive focus—causing it to be lost entirely.

How?

Similar to how the Change Template modal closes without affecting the parent dropdown, this PR ensures that closing the template creation dialog only dismisses the dialog itself. This prevents the parent dropdown from closing, allowing focus to be retained properly.

Testing Instructions

  1. Open a page.
  2. Sidebar > Page tab.
  3. Click the button next to the Template label.
  4. Open the Create new template dialog.
  5. Hit the ESC button or click the Cancel button.
  6. Confirm that the parent dropdown is not closed and the focus is retained.

Testing Instructions for Keyboard

Same.

Screencast

PR.mov

@yogeshbhutkar yogeshbhutkar marked this pull request as ready for review March 27, 2025 04:46
@github-actions

github-actions Bot commented Mar 27, 2025

Copy link
Copy Markdown

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 props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: yogeshbhutkar <yogeshbhutkar@git.wordpress.org>
Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>
Co-authored-by: t-hamano <wildworks@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@Mamaduka Mamaduka added [Type] Bug An existing feature does not function as intended [Focus] Accessibility (a11y) Changes that impact accessibility and need corresponding review (e.g. markup changes). [Feature] Document Settings Document settings experience labels Mar 27, 2025
@Mamaduka

Copy link
Copy Markdown
Member

Thanks, @yogeshbhutkar!

Rebasing should resolve failing e2e tests.

@yogeshbhutkar yogeshbhutkar force-pushed the fix-69722/focus-post-template-panel branch from 48a1bfe to 980948f Compare March 27, 2025 08:51
@yogeshbhutkar

Copy link
Copy Markdown
Contributor Author

Thanks for the review, @Mamaduka!

@Mamaduka Mamaduka merged commit 20fb420 into WordPress:trunk Mar 27, 2025
@github-actions github-actions Bot added this to the Gutenberg 20.6 milestone Mar 27, 2025
@t-hamano

Copy link
Copy Markdown
Contributor

@yogeshbhutkar Thanks for the fix!

chriszarate pushed a commit to chriszarate/gutenberg that referenced this pull request Jul 1, 2025
…tion dialog (WordPress#69724)

Co-authored-by: yogeshbhutkar <yogeshbhutkar@git.wordpress.org>
Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>
Co-authored-by: t-hamano <wildworks@git.wordpress.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Feature] Document Settings Document settings experience [Focus] Accessibility (a11y) Changes that impact accessibility and need corresponding review (e.g. markup changes). [Type] Bug An existing feature does not function as intended

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Post Template Panel: Focus loss on "Create custom template" panel

3 participants