Open scottaohara opened 1 month ago
So with that initial post out of the way, I of course have thoughts: (though i make no claim to how good they are):
There needs to be clear author expectations for the use of the "button" within a select as well. I'm starting to wonder if it's really necessary to even have that button, just like it didn't end up being necessary to have the datalist to contain the options.
But if that can't be changed at this point, then there probably needs to be very clear expectations set that this instance of a button should not be considered the same as if someone was using a button outside of a select. Since, the button isn't even really used in the a11y tree. being a child of the combobox or popup button parent (the select element), it's more of a styling element than an actual "button". People shouldn't expect to put HTML button attributes or ARIA attributes on that and expect anything meaningful to happen. At least, that's what i think about this right now - lest a rather significant change be made to how this is exposed to the a11y tree.
Thank you for looking at this!! I'm going to close my issue in favor of this, although I listed some examples there: https://github.com/openui/open-ui/issues/1116
selectedoption (or whatever it will be named) should arguably be treated like the slot element, in that it should be made very clear to authors that, even though global html attributes can be set on it - because 'global' - none of those should be expected to work if the element is used within a select > button. Similar with ARIA attributes.
Sounds good to me. The slot element already says it accepts global attributes in the HTML spec, so I'm not sure if I can/should account for this in the HTML spec: https://html.spec.whatwg.org/multipage/scripting.html#the-slot-element
There needs to be clear author expectations for the use of the "button" within a select as well. I'm starting to wonder if it's really necessary to even have that button, just like it didn't end up being necessary to have the datalist to contain the options.
The alternative I can think of is having <div slot=button>
from selectlist, which we removed in response to whatwg feedback here: https://github.com/openui/open-ui/issues/702
Perhaps for select multiple we can avoid this problem by not using/rendering a child button at all, and forcing people to build their own popovers since rendering multiple selected options in the button sounds too hard: https://github.com/openui/open-ui/issues/1102
Since, the button isn't even really used in the a11y tree.
From the rendering and focus point of view which I implemented, the button element is sort of the main thing. I started setting delegatesFocus on the select element when a child button is inserted into the select in order to make the button become the thing that gets focus.
I didn't end up setting display:contents on the select element either, so it still has a box that gets rendered, but I used UA style magic to remove borders and box decorations from the select when a button is present.
Anyway, yeah I'm not sure which of these two elements we should recommend putting accessibilty attributes etc. on.
Again, on the topic of the button, adding text/other content within the button seems like it will be a footgun. I recall that some of the rational there was that people wanted to be able to maybe add their own chevron to the button part and use an actual SVG for that. Or adding text like "choose:" before the selectedoption being essentially throwaway text, since it will be ignored. But, as anyone can put anything into that button part - do we anticipate that?
I'm not sure exactly how common it will be, but yes I think we should anticipate this and consider if/how to incorporate it into accessibility mappings.
We probably need to define a value computation algorithm. ARIA has a plan to do this for custom ARIA elements like combobox, but it seems now there's a need for select since the value can be calculated from things that aren't even defined in HTML (e.g., aria-label).
Yes I agree. How do we proceed? I'm guessing the answer to this would resolve https://github.com/openui/open-ui/issues/1116
the visible value returned to the selectedoption (not necessarily content outside of the selectedoption) probably should be what the value is exposed as. I think it's really weird that if a user chooses an option in the popup, the returned value could be displayed as / announced as something else entirely - but, if someone's going to do that, all users should arguably get that weird experience, and not have a difference between what you see vs what you might hear.
I'm guessing this is the same question - what should be announced here?
<select>
<button>
<selectedoption></selectedoption>
im a button
</button>
<option>hello</option>
<option label=labeltext>innertext</option>
</select>
The Open UI Community Group just discussed select: clarifying what should be used as the chosen value
.
For some more thought, here is an existing example of a select element at https://x.com/settings/profile
There's a label inside the button, so the label is "Month", and the value is "February". Here is a demo I made of the same thing in customizable select, which uses aria-label to set the label to "Month": https://jsfiddle.net/jarhar/t03aw7dx/35/
And if you didn't want to repeat the text "month", you would give the <div class=label>
element an id, and use aria-labelledby=[id].
i think it's important to call out that there's no reason the label needs to be in the button part though. we did purposefully remove the use of the label element within the select/its button part, since that would go against current HTML guidance for how to use the label element.
We had also resolved that anything in the button part would become part of the calculation for the select's value - so i'm not seeing how this would solve the duplicate month announcement - unless this is suggesting that repeat content would be pruned from the accessible name?
i made up the same example in another codepen, using the label element to surround the select, so as to not put the 'label' into the button. https://codepen.io/scottohara/pen/JjgxNRJ
one thing i noticed that is a problem with these demos, is that the label element should have made it so the entire visible select could have been clickable with a mouse to open the select's popup. but it doesn't seem that's working right now. I "have" to press on the button part specifically. similarly in the jsfiddle joey created, i can't click on any part of the select that isn't the button part to open the select. That seems wrong... but i'd assume will be resolved by some of the newer resolutions to treat the select as the primary element, and the button part as inert/inert-ish
And if you didn't want to repeat the text "month", you would give the
<div class=label>
element an id, and use aria-labelledby=[id].
again, unless i'm missing something here, i think if one were to do this they'd have to aria-label or aria-labelledby 'month' to be the name of the select, and then also know to aria-hidden=true the instance of the .label
in the markup, so that it wouldn't take part in contributing to the value.
these might serve as two good examples of how to achieve the same visual effect, but noting CSS hoops or the ARIA hoops that one would still have to jump through, depending on the path they chose.
I don't think we should get the accessible value from the magic button's contents, but rather we should take the option that is selected, and use its subtree. If we do this, the author won't need to use aria-hidden=true. Basically, the value should be what was highlighted in the drop down, and not include any additional text before or after that comes in the button.
(Side note for Scott: the accessible value should not use any child buttons or links, because they should be associated with an action almost like aria-actions).
i understand what you're coming from. but that's the opposite of what the group previously resolved (that what is made visible in the collapsed select should be what is exposed as the value).
so, i'm fine with going that direction, but it probably means the conversation needs to be had again and people re-evaluate why they even need to put extra content into that button part. (which i still am not sold on extra content in that button part being a good idea, but i keep losing that argument)
re:
(Side note for Scott: the accessible value should not use any child buttons or links, because they should be associated with an action almost like aria-actions).
agreed, but do we have anything to mitigate for that now, without aria-actions? that was one reason i ended up thinking that getting the value from the button part might not be the worst idea, since at least there the value could be trimmed down as any invalid links/buttons would be pruned by authors setting them to display: none
Where was the resolution that we should use all the text in the button as the value?
you're right there was no declared resolution - we ran right up to the end there. i shouldn't have said "resolved" since that's a loaded term.
but from what i recall / looking back over the minutes, with comments from greg saying he expected everything in the button part to be the value, other people echoing that on the call (though not all recorded in the minutes) and the discussion about how people would want to have an empty button and thus no value exposed - i can't imagine how we would not use the content of the button as the chosen value.
We have no guardrails up for the options themselves, no way to declare what is a description vs what is the intended name/value of an option without people having to use ARIA. Which is arguably "fine". this is v1 - get something out the door and we can improve on it. But we already have demos showing the options display one thing (more content), but cloned content is then edited via display none to present a modified version of the option.
What's returned / visible is important to accurately relay when that's all someone can see/expect to hear when they're not interacting with the popup of options. But if the value is instead pulled from the chosen option, instead of what's visible in the button part - resulting in an announced value when a value is not displayed then we're providing a different experience from what people wanted in having a button with no content in it.
so again, yes... there was no formal resolution. but everything i took away from the discussion gives me impression there isn't much room to wiggle.
to put this another way, these were the points i heard:
after talking this over with @smhigley and @aleventhal, we were circling around the following proposal:
Value computed as follows:
Pros: Allows for flexibility in how a value will be exposed to users. Devs can add extra content to the button part to modify the returned content from the
Cons: arbitrary content added to the button part that was not intended to be part of the value, will be. e.g., unicode characters, or missused
Additionally:
<option> foo <button>bar</button> </option>
- the option’s name is “foo”The Open UI Community Group just discussed select: clarifying what should be used as the chosen value
, and agreed to the following:
RESOLVED: adopt the behavior described in https://github.com/openui/open-ui/issues/1117#issuecomment-2492045184
clarification on one use case stated in the minutes, as i was probably talking too fast / might have left out some nuance:
scottohara: in that same kind of examples there are a bunch of examples across Microsoft where a button part opened a listbox of options and the button had no visible content and we needed something
scottohara: combobox invoking element that doesn't need to have a visible text string and it will need a name but the value will be exposed elsewhere
it should read more as:
there are a bunch of examples that sarah was talking to me about, across Microsoft products, where there is a button part to a combobox with no visible text / value - and there was no desire for there to be, as the chosen values were returned to a textfield or list of values that accompanied the control to invoke the listbox popup. the button (select) still needs to be named, but the value is represented elsewhere, so it shouldn't be exposed if it's not actually present for the button part.
We have been talking about what the expected value / a11y exposure of the value should be if someone changes what is displayed in an option / what the accName is of an option vs what gets rendered in the selectedoption element.
There are also questions about what happens if one were to add things like aria-label to the button or selectedoption parts of the select, or adding extra content to the button part, outside of the selectedoption. Since authors might expect to be able to modify those element and have the announced value change.
To illustrate, consider the following:
https://codepen.io/scottohara/pen/mdNqxwE
Per the above, checking the chrome implementation (oct 24th 2024) the
aria-label
becomes the returned value for the select - in this case, "tire fire". From an initial a11y pov, this makes sense because when interacting with the option, this was the accName the user would have heard and what the option visually presents in the popup picker.But there is "extra text" that is visible in the button part.
The selectedoption and the button parts each have aria-labels.
The actual text that's returned "if it burns go here!" is display none in the option that appears in the popup, but the "author" made it visible in the rendered value to collapsed select (oh and "they" added a link too.... perfect, that will be keyboard focusable, but not announced at all).
None of this is exposed in the select's collapsed state, because the name of the select is "example", the value is "tire fire" and all this extra stuff? well, up until now, no valid implementation of a select or role=combobox would have allowed for these things. There is no value computation algorithm to account for these things, and there is honestly also an argument to be made that this sort of stuff should probably be not supported at all.
This issue is to hopefully start a conversation on what to do about these things, lest it just be me soap boxing, though i know you all love that so much.