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

Possibility to set 'id' attribute #1121

Open
smelamud opened this issue Feb 2, 2022 · 4 comments
Open

Possibility to set 'id' attribute #1121

smelamud opened this issue Feb 2, 2022 · 4 comments

Comments

@smelamud
Copy link

smelamud commented Feb 2, 2022

It is not possible currently to set the id attribute of Combobox, NumberPicker etc. Because of that, it is not possible to link a <label> to them using htmlFor attribute.

@jquense
Copy link
Owner

jquense commented Feb 3, 2022

Why is it not possible? It should be possible, are you staying that passing an I'd doesn't end up anywhere?

@smelamud
Copy link
Author

smelamud commented Feb 3, 2022

Exactly.

@JohnAlbin
Copy link

This is a critical accessibility bug. If we set a id value on a widget, we expect that value to be used in an id attribute in its outputted HTML.

Setting the id of a DropdownList to myID produces the following initial HTML:

<div
  role="combobox"
  id="myID_input"
  aria-owns="myID_listbox"
  aria-controls="myID_listbox"
  aria-expanded="false"
  aria-haspopup="listbox"
  aria-busy="false"
  aria-autocomplete="list" 
  aria-disabled="false" 
  aria-readonly="false" 
  tabindex="-1" 
  data-intent="mouse" 
  class="rw-dropdown-list rw-widget"
>
  <div tabindex="-1" class="rw-widget-input rw-widget-picker rw-widget-container">
    <div class="rw-dropdown-list-input">
      <input name="myName" tabindex="-1" aria-hidden="true" class="rw-detect-autofill rw-sr" value="">
      <input class="rw-dropdownlist-search" autocomplete="off" size="2" value="">
      <span class="rw-dropdown-list-value"></span>
    </div>
    <span aria-hidden="true" class="rw-btn rw-picker-caret"></span>
  </div>
</div>

As you can see it uses a id="myID_input" on the wrapping div. And it uses id="myID_listbox" on the dropdown (once it appears), but no HTML element uses id="myID".

@JohnAlbin
Copy link

If you look at how labels behave on built-in HTML inputs, you'll see that clicking on the label will shift the user focus to the input element. For example, clicking a checkbox's label will check the checkbox and make it focused and clicking a text input's label will make the text input focused.

That means the proper fix for the DropdownList is for the <input class="rw-dropdownlist-search" autocomplete="off" size="2" value=""> element to get the DropdownList's id attribute.

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

No branches or pull requests

3 participants