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

Update: legend to provide name to optgroup #2360

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

scottaohara
Copy link
Member

@scottaohara scottaohara commented Oct 22, 2024

In regards to the updated content model for the select element and its allowed children, an optgroup can have a legend element as its first child, and this legend needs to be able to name the optgroup similarly to how a legend names a fieldset.

see:
whatwg/html#10586

WPT - web-platform-tests/wpt#49645

In regards to the updated content model for the select element and its allowed children, an `optgroup` can have a `legend` element as its first child, and this `legend` needs to be able to name the `optgroup` similarly to how a `legend` names a `fieldset`.

see:
whatwg/html#10586
Copy link

netlify bot commented Oct 22, 2024

Deploy Preview for wai-aria ready!

Name Link
🔨 Latest commit 3a08912
🔍 Latest deploy log https://app.netlify.com/sites/wai-aria/deploys/6759ea2efdf3ac00083dfc45
😎 Deploy Preview https://deploy-preview-2360--wai-aria.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

open question in whatwg/html#10586 (comment) about what should take priority - legend or optgroup's label attr.

if both end up being allowed / render - then one of these could be added to the accDescription computation - instead of ignoring one or combining them into one long name.
@jnurthen jnurthen requested a review from keithamus October 24, 2024 17:16
@scottaohara scottaohara marked this pull request as draft October 24, 2024 17:19
Copy link
Member

@keithamus keithamus left a comment

Choose a reason for hiding this comment

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

Couple of minor formatting comments, but this LGTM from a spec position, modulo new resolutions from the WHATWG.

html-aam/index.html Outdated Show resolved Hide resolved
html-aam/index.html Outdated Show resolved Hide resolved
Co-authored-by: Keith Cirkel <[email protected]>
@scottaohara scottaohara requested a review from keithamus November 1, 2024 19:02
@scottaohara scottaohara marked this pull request as ready for review November 1, 2024 19:02
@scottaohara
Copy link
Member Author

@keithamus would you mind taking another look? I've updated the ordering for the optgroup naming, and added new content to how a description should be calculated.

cc @josepharhar as updates here related to my comments in the update content model for customized select PR

@scottaohara
Copy link
Member Author

scottaohara commented Nov 1, 2024

examples for tests for how name/desc steps should work

## Name from aria-labelledby and description expectation tests

test 1: name = foo
        description = n/a
<select>
    <button><selectedcontent></selectedcontent></button>
    <optgroup aria-labelledby=f>
       <div id=f>foo</div> <!-- invalid per content model -->
       <option>test
    </optgroup>
</select>


test 2: name = foo
        description = n/a
<select>
    <button><selectedcontent></selectedcontent></button>
    <optgroup aria-labelledby=f aria-label=bar>
       <div id=f>foo</div> <!-- invalid per content model -->
       <option>test
    </optgroup>
</select>


test 3: name = foo
        description = bar
<select>
    <button><selectedcontent></selectedcontent></button>
    <optgroup aria-labelledby=f title=bar>
       <div id=f>foo</div> <!-- invalid per content model -->
       <option>test
    </optgroup>
</select>


## Name from aria-label and description expectation tests

test 1: name = foo
        description = n/a
<select>
    <button><selectedcontent></selectedcontent></button>
    <optgroup aria-label=foo>
        <option>test
    </optgroup>
</select>

test 2: name = foo
        description = bar
<select>
    <button><selectedcontent></selectedcontent></button>
    <optgroup aria-label=foo title=bar>
        <option>test
    </optgroup>
</select>



## Name from label attribute and description expectation tests

test 1: name = foo
        description = n/a
<!-- primary use case, no naming mechanism aside from label attribute -->
<select>
    <button><selectedcontent></selectedcontent></button>
    <optgroup label=foo>
        <option>test
    </optgroup>
</select>


test 2: name = bar
        description = foo
<!-- aria-label provided which wins out over label attr, but label attr's value is rendered, so still
     expose it as a description so the information is at least still available to AT -->
<select>
    <button><selectedcontent></selectedcontent></button>
    <optgroup aria-label=bar label=foo>
        <option>test
    </optgroup>
</select>


test 3: name = foo
        description = bar
<select>
    <button><selectedcontent></selectedcontent></button>
    <optgroup label=foo title=bar>
        <option>test
    </optgroup>
</select>


## Name from legend element and description expectation tests

test 1: name = foo 
        description = n/a
<!-- primary use case, no naming mechanism aside from legend element -->
<select>
    <button><selectedcontent></selectedcontent></button>
    <optgroup>
        <legend>foo</legend>
        <option>test
    </optgroup>
</select>

test 2: name = foo 
        description = n/a
<!-- label attr value is not to render because legend is specified -->
<select>
    <button><selectedcontent></selectedcontent></button>
    <optgroup label=bar>
        <legend>foo</legend>
        <option>test
    </optgroup>
</select>

test 3: name = bar 
        description = foo
<!-- aria-label provided which wins out over legend, but legend is rendered, so still
     expose it as a description so the information is at least still available to AT -->
<select>
    <button><selectedcontent></selectedcontent></button>
    <optgroup aria-label=bar>
        <legend>foo</legend>
        <option>test
    </optgroup>
</select>

test 4: name = bar 
        description = foo
<!-- aria-labelledby provided which wins out over legend, but legend is rendered, so still
     expose it as a description so the information is at least still available to AT -->
<select>
    <button><selectedcontent></selectedcontent></button>
    <optgroup aria-labelledby=b>
        <div id=b>bar</div> <!-- invalid per content model -->
        <legend>foo</legend>
        <option>test
    </optgroup>
</select>


test 5: name = foo 
        description = bar
<!-- legend provides name, title provides description -->
<select>
    <button><selectedcontent></selectedcontent></button>
    <optgroup title=bar>
        <legend>foo</legend>
        <option>test
    </optgroup>
</select>


## Name from title attribute and description expectation tests

test 1: name = foo 
        description = n/a
<!-- primary use case, no naming mechanism provided aside from title attribute -->
<select>
    <button><selectedcontent></selectedcontent></button>
    <optgroup title=foo>
        <option>test
    </optgroup>
</select>


test 2: name = foo 
        description = n/a
<!-- empty label would otherwise result in no accName - use title as fallback -->
<select>
    <button><selectedcontent></selectedcontent></button>
    <optgroup label title=foo>
        <option>test
    </optgroup>
</select>

test 3: name = foo 
        description = n/a
<!-- empty legend would otherwise result in no accName - use title as fallback -->
<select>
    <button><selectedcontent></selectedcontent></button>
    <optgroup title=foo>
        <legend></legend>
        <option>test
    </optgroup>
</select>

test 4: name = foo
        description = n/a
<!-- empty aria-label would otherwise result in no accName - use title as fallback -->
<select>
    <button><selectedcontent></selectedcontent></button>
    <optgroup aria-label title=foo>
        <legend></legend>
        <option>test
    </optgroup>
</select>

test 5: name = foo
        description = n/a
<!-- aria-labelledby points to empty element which would otherwise result in no accName - use title as fallback -->
<select>
    <button><selectedcontent></selectedcontent></button>
    <optgroup aria-labelledby=f title=foo>
        <div id=f></div>
        <legend></legend>
        <option>test
    </optgroup>
</select>

Copy link
Member

@keithamus keithamus left a comment

Choose a reason for hiding this comment

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

Still LGTM

@scottaohara scottaohara marked this pull request as draft November 12, 2024 22:23
@scottaohara
Copy link
Member Author

scottaohara commented Nov 12, 2024

put back into the draft state as I need to revise the bits about how a label attribute and legend element should no longer be expected to render at the same time. re: https://issues.chromium.org/issues/378601807

@josepharhar
Copy link

put back into the draft state as I need to revise the bits about how a label attribute and legend element should no longer be expected to render at the same time. re: https://issues.chromium.org/issues/378601807

If you have a recommendation for what to do in this case, let me know and/or comment on the crbug. I haven't implemented anything yet to account for the case where both are present.

@scottaohara
Copy link
Member Author

@josepharhar i think it's totally fine to only have one render / and have a preference for the legend element in this case since it'll allow for authors to do more.

  • if only label attribute is specified, render that to be consistent with prior select functionality
  • if only legend is specified, render that and if the select is loaded in a browser that doesn't support customization, there is no fallback
  • if both are specified,
    • in browsers that support customization render legend element as the group label and do not render label attribute text
    • in browsers that don't support customization render the fallback label attribute text as the group label

revised to incorporate latest decisions on how the naming/desc should work
@scottaohara scottaohara marked this pull request as ready for review December 11, 2024 20:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants