charcoal icon indicating copy to clipboard operation
charcoal copied to clipboard

Feat: `aria-labelledby`相当の機能が`Switch`にほしいです

Open mj-hd opened this issue 8 months ago • 1 comments

必要だと思う機能の内容を書いてください

他の構造的に離れた要素でラベルを提供しているUIを表現するためaria-labelledbyかそれと同等の機能がほしいです

この機能が必要と考えられる理由を書いてください

APGによると、switchロールはaria-labelや視覚可能なテキストコンテンツの代わりにaria-labelledby属性を指定することができるとあります。 https://www.w3.org/WAI/ARIA/apg/patterns/switch/

現在の実装だと、labelか、childrenしか受け取りません。 https://github.com/pixiv/charcoal/blob/de4162c889061d424c034459e498a4f7eae18960/packages/react/src/components/Switch/index.tsx#L18

この機能があった場合にどういう動きをするかの例を書いてください

react-ariaのuseSwitchのariaPropsにこれらの値が渡り、いろいろなユーザエージェントがこれを読み取れる状態。

また、他にもaria属性はいくつかサポートされていて、aria-description/aria-describedbyなどの追加テキスト情報を提供できるものや、aria-controlsによる操作対象のUIを指定できるものがありそうです。


Switch control should expose aria-labelledby props

According to APG, switch role may have an aria-labelledby attr instead of aria-label. https://www.w3.org/WAI/ARIA/apg/patterns/switch/

In the current implementation, the Switch component only exposes aria-label and children as text content. https://github.com/pixiv/charcoal/blob/de4162c889061d424c034459e498a4f7eae18960/packages/react/src/components/Switch/index.tsx#L18

(...and, there are more aria props, aria-description and aria-describedby, aria-details attrs to represent additional text content, aria-controls to represent content controlled by the switch.)

mj-hd avatar Jun 24 '24 06:06 mj-hd