Open mj-hd opened 3 weeks ago
Issueの作成およびフィードバックをいただき、誠にありがとうございます。
v4.0.0の変更により、Switchのinput要素に対して任意の属性を付与できるようになる予定です。そのため、申し訳ありませんが現在 v3 のAPIに変更を加える事は検討されていません。
v4.0.0のリリース時にご確認いただければ幸いです。また、現在beta版もリリースしておりますので、そちらでもご確認いただく事ができます。
参考までに、下記はv4.0.0のSwitchのコードになります。 https://github.com/pixiv/charcoal/blob/6ce3eaf89f87ceec7cd0b5031c3f6227096c289d/packages/react/src/components/Switch/index.tsx
必要だと思う機能の内容を書いてください
他の構造的に離れた要素でラベルを提供している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 anaria-labelledby
attr instead ofaria-label
. https://www.w3.org/WAI/ARIA/apg/patterns/switch/In the current implementation, the
Switch
component only exposesaria-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
andaria-describedby
,aria-details
attrs to represent additional text content,aria-controls
to represent content controlled by the switch.)