Skip to content

Added default focus and hover states to accordion header#71937

Merged
t-hamano merged 3 commits intoWordPress:trunkfrom
n2erjo00:bugfix/accordion-header-default-focus-and-hover-state
Sep 29, 2025
Merged

Added default focus and hover states to accordion header#71937
t-hamano merged 3 commits intoWordPress:trunkfrom
n2erjo00:bugfix/accordion-header-default-focus-and-hover-state

Conversation

@n2erjo00
Copy link
Copy Markdown
Contributor

What?

Closes #71777

This PR adds default hover and focus states to accordion header

Why?

Hover and focus states are important parts of accessibility

How?

  • Instead of -webkit-focus-ring-color to color the outline ring use currentColor
  • Added good old text-decoration: underline as hover state
    • Specifically targeting the title element inside the button to add underline. It look bit unpleasant (to me) to underline both because of the empty space between the text and icon

Testing Instructions

  1. Remember to add "Blocks: add experimental blocks" in /wp-admin/admin.php?page=gutenberg-experiments
  2. Insert Accordion to any Page or Post
  3. Hover over the Accordion header panel and observe the effect
  4. Navigate to the Accordion header with tab and observe the effect

Testing Instructions for Keyboard

Screenshots or screencast

Before After

@github-actions
Copy link
Copy Markdown

github-actions bot commented Sep 28, 2025

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: n2erjo00 <n2erjo00@git.wordpress.org>
Co-authored-by: t-hamano <wildworks@git.wordpress.org>
Co-authored-by: joedolson <joedolson@git.wordpress.org>

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

Copy link
Copy Markdown
Contributor

@t-hamano t-hamano left a comment

Choose a reason for hiding this comment

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

Thanks for the PR!

The changes look good to me, but personally, I would like to respect the browser's default outline as much as possible and remove the offset as well.

What do you think of the following approach?

.wp-block-accordion-header__toggle {
	// ...

	&:not(:focus-visible) {
		outline: none;
	}

	&:hover .wp-block-accordion-header__toggle-title {
		text-decoration: underline;
	}
}

@t-hamano t-hamano 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). [Block] Accordion Affects the Accordion Block labels Sep 29, 2025
@n2erjo00
Copy link
Copy Markdown
Contributor Author

@t-hamano Makes sense to me. I cleared all the styles from toggle that would customize outline

Copy link
Copy Markdown
Contributor

@t-hamano t-hamano left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@t-hamano t-hamano merged commit c09260a into WordPress:trunk Sep 29, 2025
68 checks passed
@github-actions github-actions bot added this to the Gutenberg 21.8 milestone Sep 29, 2025
adamsilverstein pushed a commit to adamsilverstein/gutenberg that referenced this pull request Sep 29, 2025
…1937)

* Added default focus and hover states to accordion header

* Update focus style. Removed outline offset

* Update focus style. Remove the outline styles that look 'custom'

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

Labels

[Block] Accordion Affects the Accordion Block [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.

Accordion Block: No default focus or hover state

2 participants