question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

feat: allow multiple opaque identifiers in HTML attributes

See original GitHub issue

react version: #17322 Original: https://github.com/facebook/react/pull/17322#issuecomment-613104823

Currently only a single value from useOpaqueIdentifier (unreleased) can be passed to HTML attributes. However, there are HTML attributes which support multiple ids (IDREFS) like aria-labelledby. This can be used to implement various patterns such as:

export default function App() {
  const taxpayerId = React.unstable_useOpaqueIdentifier();
  const spouseId = React.unstable_useOpaqueIdentifier();
  const w2GrossId = React.unstable_useOpaqueIdentifier();
  const dividendsId = React.unstable_useOpaqueIdentifier();
  return (
    <table>
      <tbody>
        <tr>
          <td />
          <th id={taxpayerId}>Taxpayer</th>
          <th id={spouseId}>Spouse</th>
        </tr>

        <tr>
          <th id={w2GrossId}>W2 Gross</th>
          <td>
            <input type="text" aria-labelledby={[taxpayerId, w2GrossId]} />
          </td>
          <td>
            <input type="text" aria-labelledby={[spouseId, w2GrossId]} />
          </td>
        </tr>

        <tr>
          <th id={dividendsId}>Dividends</th>
          <td>
            <input type="text" aria-labelledby={[taxpayerId, dividendsId]} />
          </td>
          <td>
            <input type="text" aria-labelledby={[spouseId, dividendsId]} />
          </td>
        </tr>
      </tbody>
    </table>
  );
}

https://codesandbox.io/s/useopaqueidentifier-for-idrefs-ocnm4

This example is from https://www.w3.org/WAI/GL/wiki/Using_aria-labelledby_to_concatenate_a_label_from_several_text_nodes

This currently almost works but it concatenates the ids with "," (default toString of arrays) instead of " ".

<button aria-labelledby={[opaqueIdentifier1, opaqueIdentifier1]} /> is to me the most intuitive one since we’re passing a list of ids.

Edit: Removed the collapsible listbox example since that pattern has some a11y issue.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:9
  • Comments:10 (3 by maintainers)

github_iconTop GitHub Comments

5reactions
gaearoncommented, Mar 24, 2021

I’ve added a label to revisit so that stale bot stops trying to close this.

4reactions
awearycommented, Apr 13, 2020

@eps1lon I believe you can safely get around this for now by using a custom class that extends Array and overrides toString.

Read more comments on GitHub >

github_iconTop Results From Across the Web

id - HTML: HyperText Markup Language - MDN Web Docs
The id global attribute defines an identifier (ID) which must be unique ... Warning: This attribute's value is an opaque string: this means ......
Read more >
Encoded Archival Description Tag Library - Version EAD3 ...
This tag library represents version EAD3 1.1.1 of the Encoded Archival ... For example, id attribute is of type ID, which constrains its...
Read more >
Layers — GeoServer 2.22.x User Manual
Layers can be divided into two types of data: raster and vector. These two formats differ ... Name—Identifier used to reference the layer...
Read more >
Id attribute value is unique[proposed] | ACT Rule | WAI - W3C
The value of the attribute is unique across all other id attributes specified on HTML or SVG elements that exist within the same...
Read more >
A Complete Guide to Data Attributes | CSS-Tricks
HTML elements can have attributes on them that are used for anything from accessibility information to stylistic control. <!-- We can use the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found