Make WordPress Core

Opened 4 months ago

Closed 2 months ago

Last modified 2 months ago

#65153 closed defect (bug) (fixed)

Identify selected buttons (.active in button groups) in Windows High Contrast Mode

Reported by: sabernhardt Owned by: joedolson
Priority: normal Milestone: 7.1
Component: Administration Version:
Severity: normal Keywords: has-patch commit
Cc: Focuses: accessibility, css

Description (last modified by sabernhardt)

Buttons within groups do not distinguish which buttons are selected in Windows High Contrast Mode.

This includes:

  • custom options in Permalink Settings
  • alignment options in the Image details dialog (when replacing an image within a post in classic editor)

Before patch: alignment options in the Image details dialog do not show that 'None' is selected

Attachments (2)

Align-None-selected-without-focus.png (30.6 KB ) - added by sabernhardt 4 months ago.
Before patch: alignment options in the Image details dialog do not show that 'None' is selected
customizer-button-active.png (166.2 KB ) - added by wildworks 3 months ago.
Customizer: Style for an active Publish Settings button

Download all attachments as: .zip

Change History (22)

This ticket was mentioned in PR #11680 on WordPress/wordpress-develop by @sabernhardt.


4 months ago
#1

  • Keywords has-patch added

Adds a transparent pseudo-element on active buttons. In Windows High Contrast mode, this shows a thin border on three sides and a thicker border on the bottom.

Using a pseudo-element reduces the chance of confusion with the focus outline, and it does not change the border (and button height) for other users.

Trac 65153

## Screenshots

Screenshots using:

  • Windows 11
  • Aquatic contrast theme plus Dark mode
  • Chrome 147.0.7727.102

### Permalinks options, showing focus outline on selected post name button

Before
https://github.com/user-attachments/assets/0768bce1-1d71-4bc9-b322-4f561ddc5e9f

With patch (this also shows hover style on post_id button)
https://github.com/user-attachments/assets/7bc8783d-92b3-4a62-91a1-c8dbdcaf19a2

### Alignment options

The 'None' button is selected.

#### Selected None button has focus outline

Before
https://github.com/user-attachments/assets/c95ee48e-e290-4863-8ca9-2a34210f4903

With patch
https://github.com/user-attachments/assets/47fe849f-14c3-431b-ad0b-e5f942e484eb

#### Unselected Left button has focus outline

Before
https://github.com/user-attachments/assets/84f3ade2-aafd-49f6-a914-b9dae098a4ee

With patch
https://github.com/user-attachments/assets/c48d8cf2-22a7-496d-9372-24154a32591a

## Use of AI Tools

none

@sabernhardt
4 months ago

Before patch: alignment options in the Image details dialog do not show that 'None' is selected

#2 @sabernhardt
4 months ago

  • Description modified (diff)

@wildworks commented on PR #11680:


4 months ago
#3

What are your thoughts on applying a 3px border to all four sides, rather than just the bottom?

https://github.com/user-attachments/assets/019fa96d-824e-4210-a5ed-0a68e512d630
https://github.com/user-attachments/assets/f4cb1cce-6235-4a7f-9ff8-0d2fb035f3c7

@sabernhardt commented on PR #11680:


4 months ago
#4

What are your thoughts on applying a 3px border to all four sides, rather than just the bottom?

That could be better. I also considered a border only on the bottom.

https://github.com/user-attachments/assets/f731d0e8-6958-4cff-a38a-fc5cb938e352

The hover state is the same as the default state:

https://github.com/user-attachments/assets/588e79a5-2abb-4f19-b412-4c2dd5623281

@wildworks commented on PR #11680:


4 months ago
#5

Thanks for the suggestion.Personally, I believe the third approach is the best. I find it particularly intuitive compared to the other two, especially when the active button is in focus. The focus color does not conflict with the button's default outline.

https://github.com/user-attachments/assets/9aae225e-0f16-430c-9de7-fc5829a784f4

#6 @manhar
4 months ago

Agreed with @wildworks — the third approach feels the most natural. Tested it in Windows High Contrast Mode and the active button state is clearly distinguishable without conflicting with the focus outline. The teal border works well for indicating the selected state.

This ticket was mentioned in Slack in #accessibility by joedolson. View the logs.


3 months ago

#8 @joedolson
3 months ago

  • Milestone Awaiting Review7.1
  • Owner set to joedolson
  • Status newaccepted

I have some preference for using the first approach, since it would meet WCAG 2.4.13, but it's not required, so I'm willing to bend on that.

#9 @joedolson
3 months ago

  • Keywords commit added

#10 @joedolson
3 months ago

  • Resolutionfixed
  • Status acceptedclosed

In 62467:

Administration: Fix button active states in high contrast mode.

Adds CSS to distinguish button selected or active states in Windows High Contrast Mode.

Props sabernhardt, wildworks, manhar, joedolson.
Fixes #65153.

#11 @joedolson
3 months ago

  • Keywords dev-feedback added
  • Resolution fixed
  • Status closedreopened

Reopening for backport to 7.0 branch.

#12 @wildworks
3 months ago

  • Keywords commit dev-feedback removed

The approach using pseudo-elements might not have been the best, as the pseudo-elements get overridden when the button with the dashicon changes to an active state.

<button  class="button-primary button dashicons dashicons-admin-generic active">Button</button>

/* Only visible in Windows High Contrast mode */
.wp-core-ui .button.active:before {
    content: "";
}


/* This CSS will be overridden. */
.dashicons-admin-generic:before {
    content: "\f111";
}

For example, activate the "Publoish setting" button in Customizer. The dashicon will disappear.

By the way, the issue reported here should have been occurring previously, so I don't think it needs to be backported to 7.0.1.

@wildworks
3 months ago

Customizer: Style for an active Publish Settings button

#13 follow-up: @sabernhardt
3 months ago

  • Keywords has-patch removed

Switching the new pseudo-element from :before to :after could be a quick fix, at least for the Customizer Publish Settings button.

Or might you prefer another way to style the buttons, perhaps with the (forced-colors: active) media query?

#14 in reply to: ↑ 13 ; follow-up: @wildworks
3 months ago

Replying to sabernhardt:

Switching the new pseudo-element from :before to :after could be a quick fix, at least for the Customizer Publish Settings button.

At its core, it should be safe as there shouldn't be any cases where the .active class and the ::after pseudo-element are used simultaneously. However, third-party developers might have implemented such a combination on their own.

.wp-core-ui .button.active.my-plugin::after {
    content: "Content";
}

Or might you prefer another way to style the buttons, perhaps with the (forced-colors: active) media query?

I'm concerned that the forced-colors media query is not being used at all in the core. Is there any particular reason for this?

#15 in reply to: ↑ 14 @sabernhardt
3 months ago

::after pseudo-element

Lowering the specificity to :where(.wp-core-ui .button.active)::after could decrease the chance of collision with plugins, but that still has the potential to break plugins' CSS.

I'm concerned that the forced-colors media query is not being used at all in the core. Is there any particular reason for this?

Limiting the scope to only high contrast mode seemed necessary. I did not like editing either the border or the outline of the button itself.

  • Changing an .active button's border width affects its overall dimensions.
  • Using outline for the selected state can lead to confusion with the focus outline.

I'll add another PR to consider a transparent outline with a negative offset, where the outline width increases on focus. It is not particularly intuitive, but it should be an improvement compared to previous releases.

This ticket was mentioned in PR #12242 on WordPress/wordpress-develop by @sabernhardt.


3 months ago
#16

  • Keywords has-patch added
  • Reverts r62467 to remove pseudo-element.
  • Adds a transparent outline to the .active buttons, with a negative outline offset.
  • Increases the width of the outline for the focus state.

Trac 65153

Use of AI Tools: none

This ticket was mentioned in Slack in #accessibility by joedolson. View the logs.


2 months ago

#18 @joedolson
2 months ago

  • Keywords commit added

#19 @joedolson
2 months ago

  • Resolutionfixed
  • Status reopenedclosed

In 62567:

Administration: Fix selected/active buttons in High Contrast Mode.

Follow up to [62467]. Replaces original fix, which turned out to be insufficient. Replaces pseudo-elements with more standard outlines, shifted in scale for visibility.

Props sabernhardt, wildworks, apermo, joedolson.
Fixes #65153.

@sabernhardt commented on PR #12242:


2 months ago
#20

Committed in r62567

Note: See TracTickets for help on using tickets.