Skip to content
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

TextTransformControl/TextDecorationControl: Balancing usability and accessibility #36735

Closed
mirka opened this issue Nov 22, 2021 · 17 comments · Fixed by #43328 or #44067
Closed

TextTransformControl/TextDecorationControl: Balancing usability and accessibility #36735

mirka opened this issue Nov 22, 2021 · 17 comments · Fixed by #43328 or #44067
Assignees
Labels
[Feature] Component System WordPress component system [Status] In Progress Tracking issues with work in progress [Type] Discussion For issues that are high-level and not yet ready to implement.

Comments

@mirka
Copy link
Member

mirka commented Nov 22, 2021

There has been some complications in finding the correct implementation for the TextTransformControl and TextDecorationControl components (e.g. #26060 #31623). It seems like the difficulty is in making the implementation semantically correct, while also being intuitively usable for sighted users.

Text Transform and Text Decoration controls

Considered implementations

Pros Cons
Radio (ToggleGroupControl) Mutually exclusive Cannot re-click to reset (or requires a separate "default" option)
Group of buttons Can click to reset Not mutually exclusive
Rely on ToolsPanel reset Can use Radio Not intuitive

The options items are mutually exclusive, which makes them similar to a radio control. But we also want an intuitive way to reset the control, which is currently achieved by clicking the active item again. We can't implement this behavior onto a radio control because radio buttons are expected to be idempotent.

On the other hand, a mere array of buttons, even if role="group"ed, fails to semantically capture the mutual exclusivity of the options.

Any ideas or thoughts? (cc @ciampo @diegohaz)

@mirka mirka added [Type] Discussion For issues that are high-level and not yet ready to implement. [Feature] Component System WordPress component system labels Nov 22, 2021
@ciampo
Copy link
Contributor

ciampo commented Nov 22, 2021

Inspired by #31623 (comment), I think the most correct option would be to use ToggleGroupControl and add an additional option for the "None" case represented with a icon.

We could make sure that, when the control is supposed to be "reset" (initial value, and ToolsPanel reset), the "None" option gets selected.

Also pinging @jasmussen in case he had any feedback.

@jasmussen
Copy link
Contributor

Thanks for the ping! My instinct here is to embrace the approach we are taking with the tools panel. Which is:

  • Text decoration and letter case controls should probably never be shown in a tools panel by default: they are something you add from the ellipsis menu.
  • Since they are mutually exclusive, they'd have the same behavior as a radio group. Whether the underlying markup uses radios, I don't personally have a strong opinion on.
  • In being part of the ToolsPanel, the same reset mechanism should be used as is used for other controls. That is, you reset from the tools panel, not from any dedicated interface in the control itself.

Here's the latest Tools Panel mockup:
tools panel

  • To reset Line-height, just uncheck line-height. It clears the value and hides the control.
  • "Size" is shown by default. To clear it, click the minus. The minus only appears if the control has been customized.
  • Clicking "Reset all" in the above mockup, would hide line-height and letter spacing controls, and clear the customized value for the Size control.

The balance to strike here is one of "clearing" values being a rare thing you do, so the tools to clear shouldn't need that much prominence. It's something we can always revisit based on feedback, but I think it's worth it to move down this path for now.

@noisysocks
Copy link
Member

@jasmussen: It's a good idea but we don't use a tools panel in Global Styles. We want to show Letter case in Global Styles for headings, see #34345 (comment). Any ideas on how to unset the value there?

Screen Shot 2022-08-18 at 15 52 37

@jasmussen
Copy link
Contributor

Right! I don't mean to be facetious with the following GIF showing that you can just click the toggled state to untoggle it again:

unset

I genuinely believe we shouldn't optimize too hard for reset buttons. Bold text you'd unset the same way, appearance you can set back to default, line-height you can select and delete. Reset buttons in an ellipsis (in the future) provide an additional affordance, but isn't the main affordance.

@mirka
Copy link
Member Author

mirka commented Aug 18, 2022

@noisysocks What I understood was that we want to lean into the central reset mechanisms, which is this one in Global Styles:

Actions dropdown menu in Global Styles with the Reset to defaults option

If we were to improve the flow, I think that menu button could be split into per-control resets instead of a whole panel rest.

@noisysocks
Copy link
Member

noisysocks commented Aug 23, 2022

Right! I don't mean to be facetious with the following GIF showing that you can just click the toggled state to untoggle it again:

To implement this behaviour where you click to un-toggle we'd have to make the controls a group of buttons instead of a radio. This isn't great as a group of buttons doesn't convey that the options are mutually exclusive to folks who are using assistive technologies.

@noisysocks What I understood was that we want to lean into the central reset mechanisms, which is this one in Global Styles:

The Reset to defaults button resets all settings, no? I think it's too nuclear and could lead to user confusion/frustration.


How do we all feel about @ciampo's suggestion as a solution for this in Global Styles?

Inspired by #31623 (comment), I think the most correct option would be to use ToggleGroupControl and add an additional option for the "None" case represented with a icon.

Just a thought, but I wonder if we could have a "none" option in the radio control that is visually hidden but appears for assistive technology users?

@jasmussen
Copy link
Contributor

@jameskoster I feel like you've had some thoughts about a radio group with a minus reset button.

@jameskoster
Copy link
Contributor

I don't know if it's the right approach, but I lean towards building a UI which essentially replicates the CSS you'd write in order to achieve these things.

As an example, if I set all headings to be uppercase, but there's one heading that I want to display as typed, then I would target that heading and declare text-transform: initial.

So in this case, if we want to display the control regardless of whether a value is set, then we need:

  1. It to communicate when the inherent default is applied
  2. A way for users to select the inherent default as a part of the control, so that they can override styles upstream in the cascade.

For me, a icon which translates to text-transform: initial makes the most sense. It also aligns with the semantic desire to make the control behave like a radio.

@jasmussen
Copy link
Contributor

I don't know if it's the right approach, but I lean towards building a UI which essentially replicates the CSS you'd write in order to achieve these things.

I think it can be a good baseline to start from. One of the challenges here is we will very often have an additional state: unset. That is: no choice has been made. initial would be an explicit unset. Both can make sense, to be sure, especially in cases where you might inherit a text-transform from higher up the hierarchy and wanting to unset that. But it's worth keeping in mind that unset and initial are separate in this case.

@jameskoster
Copy link
Contributor

One of the challenges here is we will very often have an additional state: unset.

Going back to the 'replicate the code' concept, this would be equivalent to a style that has no text-transform declaration, correct? If so, I would not display the control at all. I think we've discussed this before, but the flow of adding a control to override an inherited default feels quite natural to me.

@jasmussen
Copy link
Contributor

The only gotcha there is in cases where we do want to surface the control by default, to aid discoverability. In that case, toggle-buttons allow the natural unset state by not having any toggled, whereas you can't go back to this untoggled state in a segmented control (similar to radios).

@jameskoster
Copy link
Contributor

jameskoster commented Aug 24, 2022

The only gotcha there is in cases where we do want to surface the control by default

True, but while discoverability is improved, there is still a confusing trade-off... For example with the Row block, the 'Block spacing' control is visible but contains no value, despite the canvas clearly demonstrating a gap:

Screenshot 2022-08-24 at 14 43 37

@jasmussen
Copy link
Contributor

Yep, that loops right back into #43082!

@apeatling
Copy link
Contributor

apeatling commented Aug 30, 2022

I wanted to flag this issue and my comment, as it raised the confusion of using the toggle group control and not being able to toggle an individual setting: #42766 (comment).

One other thing -- text-decoration is a shorthand property, so you can add multiple values. Meaning you can set line-through and underline at the same time, they aren't mutually exclusive. https://developer.mozilla.org/en-US/docs/Web/CSS/text-decoration

@jasmussen
Copy link
Contributor

Great detective work. Yes, it seems like text-decoration needs an explicit none, and that it isn't enough to assume "none" is the default.

@noisysocks
Copy link
Member

noisysocks commented Sep 6, 2022

One other thing -- text-decoration is a shorthand property, so you can add multiple values. Meaning you can set line-through and underline at the same time, they aren't mutually exclusive. https://developer.mozilla.org/en-US/docs/Web/CSS/text-decoration

Ah, that's a good point. It seems to me that Decoration should be a group of non mutually exclusive buttons and Letter case should be a radio with None as an option. Does that sound right to everyone? 😀

@noisysocks noisysocks reopened this Sep 6, 2022
@jasmussen
Copy link
Contributor

Ah, that's a good point. It seems to me that Decoration should be a group of non mutually exclusive buttons and Letter case should be a radio with None as an option. Does that sound right to everyone? 😀

As a starting point, I'd love to just see an explicit none button at the start, perhaps just using the reset icon. I would also think that to be plenty for the foreseeable future, as the use case of multiple decorations is niche to the point that we can revisit that one if/when a need actually arises.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Component System WordPress component system [Status] In Progress Tracking issues with work in progress [Type] Discussion For issues that are high-level and not yet ready to implement.
Projects
None yet
6 participants