Skip to content

[Icons] Improve aria attributes rendering #1797

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

Merged
merged 1 commit into from
Apr 30, 2024

Conversation

smnandre
Copy link
Member

@smnandre smnandre commented Apr 28, 2024

Fix: #1796

  • Convert aria boolean values to "true/false" strings (as previously done in TwigComponent)
  • Fix aria-hidden is added when source icon contains aria label
  • Add pre-rendering filter chain in IconRenderer (internal)

Update:

After discussion in this issue, i suggest we keep the current behaviour: "boolean false removes an attribute"

Attribute \ Value true false "true" "false"
required required required="true" required=false"
aria-required aria-required="true" aria-required="true" aria-required="false"

So just something to ease the DX but that let the developer responsible of setting a correct value.

@norkunas
Copy link
Contributor

Can we do this only for these attributes?: aria-atomic, aria-busy, aria-checked, aria-disabled, aria-expanded, aria-grabbed, aria-haspopup, aria-hidden, aria-invalid, aria-multiline, aria-multiselectable, aria-pressed, aria-readonly, aria-required, aria-selected

ref #1709 (comment)

@smnandre
Copy link
Member Author

First of all, sorry for the BC @norkunas

I'm very not found of having distinct behaviour for specific attributes (one per one i mean), that will be something hard to maintain.

I'd suggest another option: just hande "true" (boolean) for aria-attribute

That would work like this

Attribute \ Value true false "true" "false"
required required required="true" required=false"
aria-required aria-required="true" aria-required="true" aria-required="false"

So just something to ease the DX but that let the developer responsible of setting a correct value.

WDYT ?

@norkunas
Copy link
Contributor

norkunas commented Apr 29, 2024

It's NOT a very big list to maintain, so imho to restore previous behavior it's easy to check for those attributes, and I have a WIP code for twig components

@smnandre
Copy link
Member Author

My suggestion would not work for you ?

@norkunas
Copy link
Contributor

If you mean that real boolean false will omit the attribute from being rendered, then probably yes, okay for me :)

@smnandre
Copy link
Member Author

As it's already the case for all attributes.

The only aria specific behaiour would be transforming bool true into string "true" .

I think this could be the easiest to maintain/document

@norkunas
Copy link
Contributor

I think 'Passing "null" as an attribute value is deprecated and will throw an exception in 3.0.' was wrong, and it could easily solve this problem for me - I'd use null for omitting attributes, and then false or true could be casted to strings without a problem for me. When this deprecation was added I needed to switch from null to false

@smnandre
Copy link
Member Author

I think 'Passing "null" as an attribute value is deprecated and will throw an exception in 3.0.' was wrong, and it could easily solve this problem for me

Well we cannot change this now 🤷‍♂️

Users do want to use booleans in their code (that was a recurrent demand, same thing for icon, CVA, live attributes ...)

So i think my proposition works, but let's see what others think

@kbond @WebMamba (and everyone else :) )?

@WebMamba
Copy link
Contributor

I feel like aria is a topic more complex than that and we tried to be too opinioned about that. If we look at the doc here: https://w3.org/WAI/WCAG21/Techniques/aria/ARIA24 they don't recommend setting the aria-label to true. WDYT ?

@smnandre
Copy link
Member Author

No one wants or recommands to set the aria-label to true :) Where did you read that ?

@norkunas
Copy link
Contributor

norkunas commented Apr 30, 2024

I think 'Passing "null" as an attribute value is deprecated and will throw an exception in 3.0.' was wrong, and it could easily solve this problem for me

Well we cannot change this now 🤷‍♂️

And why not? 🙂 undeprecating is easy, isn't it? 🙂

@smnandre
Copy link
Member Author

And why not? 🙂 undeprecating is easy, isn't it? 🙂

I should have quoted more text :)

A choice has been made to use the boolean "false" to remove an attribute, as many persons asked, i don't see myself asking people to switch again and lose this feature (that would be a BC break).

kbond added a commit that referenced this pull request Apr 30, 2024
…dre)

This PR was squashed before being merged into the 2.x branch.

Discussion
----------

[TwigComponent] Fix aria attribute cannot be removed

Handle only "true" (the original need) and restore using false to remove an attribute

cf #1709 and #1797

Commits
-------

e3e9825 [TwigComponent] Fix aria attribute cannot be removed
@carsonbot carsonbot added Status: Reviewed Has been reviewed by a maintainer and removed Status: Needs Review Needs to be reviewed labels Apr 30, 2024
@kbond kbond force-pushed the feat/icon-renderer-aria branch from 65be5bb to aeded4a Compare April 30, 2024 15:06
@kbond
Copy link
Member

kbond commented Apr 30, 2024

Thanks Simon.

@kbond kbond merged commit 3a2937e into symfony:2.x Apr 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Icons Status: Reviewed Has been reviewed by a maintainer
Projects
None yet
Development

Successfully merging this pull request may close these issues.

UX icons > aria-hidden=true despite aria-label defined
5 participants