Skip to content

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

Description

@t-hamano

Description

Note: This problem is NOT new to WordPress 6.8.

When the modal is closed, the focus returns to the element that triggers the modal. However, when the "Create custom template" modal is closed. the trigger element "Create new template" button disappears, so the focus is lost.

On the other hand, when the "Choose a template" modal is closed, the focus returns correctly to the trigger element ("Change template" button).

Step-by-step reproduction instructions

Activate your screen reader and perform all of the following operations using your keyboard.

  • Open a post
  • Sidebar > Post tab
  • Click the button next to the "Template" label
  • Open the "Create new template"
  • Hit the ESC button or click the Cancel button
  • The dropdown is closed and the focus is lost.

Screenshots, screen recording, code snippet

Create new template

❌ Focus is lost

a344a694061758780b21c0c2e0a9a2fa.mp4

Change template

✅ Focus is not lost

52eccf1d5015896c029f9bc9a82176f0.mp4

Environment info

No response

Please confirm that you have searched existing issues in the repo.

  • Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

  • Yes

Please confirm which theme type you used for testing.

  • Block
  • Classic
  • Hybrid (e.g. classic with theme.json)
  • Not sure

Metadata

Metadata

Assignees

No one assigned

    Labels

    [Feature] Document SettingsDocument settings experience[Focus] Accessibility (a11y)Changes that impact accessibility and need corresponding review (e.g. markup changes).[Status] In ProgressTracking issues with work in progress[Type] BugAn existing feature does not function as intended

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions