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

Improve usecases in selectlist explainer #918

Merged
merged 3 commits into from
Nov 10, 2023

Conversation

josepharhar
Copy link
Collaborator

In response to this feedback: whatwg/html#9799 (comment)


<div className="code-image-container">
<div>
```html
<selectlist>
<option>
<img src="usa.jpg">
USA
<img src="swallow.jpg">
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do these new images exist in the repo? I don't see them but maybe I missed it.

Copy link
Collaborator

Choose a reason for hiding this comment

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

don't forget alt="" or alt

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I switched back to country flags and added alt text.
The images don't exist in the repo, but they don't need to because they aren't actually downloaded or rendered anywhere on the website - the only exist in the demo which I made locally just to create the adjacent screenshot.

<option>four</option>
<div class=container>
<div>
<div role=group>1-2</div>
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this a "good" example? I would think we should use <optgroup> instead of a handful of divs with "role=group", no?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I feel like using optgroup here would just be asking for people to say that <select> can already handle this use case.
<optgroup> has a user agent shadowroot and assigns the actual text with role=group from an attribute, which is not very robust, and <selectlist> doesn't have that limitation since youre allowed to put <div role=group>s in it.

But yeah this example does not actually do anything that optgroup can't do...

Copy link
Collaborator

Choose a reason for hiding this comment

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

I definitely think an example using <optgroup> can showcase things the <select> can't do. For example, it can contain a fully-styled <legend> element (per the resolution):

<selectlist>
  <optgroup>
    <legend><img src=cool_group_icon>Fancy group</legend>
    <option>...

site/src/pages/components/selectlist.mdx Show resolved Hide resolved
@scottaohara
Copy link
Collaborator

scottaohara commented Oct 30, 2023

it may be worth noting specifically that just using emoji wouldn't be appropriate for many graphic + text label use cases, because emojis are exposed as content.

so for instance,

<option>:gb: united kingdom</option>

would be result in this option having the accessible name of "united kingdom flag united kingdom" and that's silly. There's no good way to mark that emoji as decorative with the current select > option parsing rules either. cause even if someone did <span>:gb:</span> ... that span would be parsed out and we'd still get "united kingdom flag united kingdom".

@lukewarlow
Copy link
Collaborator

lukewarlow commented Oct 30, 2023

Not to mention flag emojis don't actually render on all platforms.

That does beg the question should aria-hidden on Scott's mentioned span have an impact on how it's parsed? Like when you're producing a value to be submitted should aria-hidden stop it being included? (Aria-hidden on the basis it's a good indication something is decorative)

@scottaohara
Copy link
Collaborator

That does beg the question should aria-hidden on Scott's mentioned span have an impact on how it's parsed? Like when you're producing a value to be submitted should aria-hidden stop it being included? (Aria-hidden on the basis it's a good indication something is decorative)

ARIA shouldn't change the behavior of HTML. It's only function is to modify how HTML is presented by the browser's accessibility tree. If someone needs to have their option submit a particular value, they should specify the value attribute on that option, and let what's rendered as the visible/programmatic name of the option be just that.

@josepharhar
Copy link
Collaborator Author

it may be worth noting specifically that just using emoji wouldn't be appropriate for many graphic + text label use cases, because emojis are exposed as content.

Not to mention flag emojis don't actually render on all platforms.

Thanks! I'll go back to country flags then, they looked nicer than the animals anyway

@josepharhar josepharhar merged commit 8897fcd into openui:main Nov 10, 2023
3 checks passed
@josepharhar josepharhar deleted the moreusecases branch April 30, 2024 17:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants