feat(Tooltip): type propの追加とchildrenのタブストップ二重問題の解消#6307
Open
schktjm wants to merge 2 commits into
Open
Conversation
Primer UIのTooltipのように、type propでツールチップの役割を選択できるようにする。 type="label"の場合はchildren要素にaria-labelledbyを付与しアクセシブルネームとして機能する。 type="description"(デフォルト)の場合は従来通りaria-describedbyを付与し補足説明として機能する。 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
commit: |
schktjm
commented
May 8, 2026
| } | ||
|
|
||
| const isFocusable = | ||
| childElement.matches('a[href], button, input, select, textarea, [tabindex]') && |
Contributor
Author
There was a problem hiding this comment.
children にフォームコントロール要素がいるかどうかの判定を、FormControl のように [data-smarthr-ui-input="true"]' などの smarthr-ui 内で定義しているものを使うか迷いましたが、 野良の button や a の見落としが発生しそうな気がして要素を指定しています
Contributor
Author
|
https://github.com/kufu/skills の |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
関連URL
https://www.notion.so/SmartHR-UI-Tooltip-type-label-description-35337b6398eb8076a66fe40f2d4a0d84?v=31737b6398eb807b8dc3000c583344f5&source=copy_link
概要
Tooltip コンポーネントに2つの機能を追加します。
typeprop の追加: Primer UI の Tooltip と同様に、'label'と'description'(デフォルト)を選択可能にし、アクセシビリティ上の役割を明確に使い分けられるようにするtabIndexの自動制御: children がフォーカス可能な要素(Button, Input 等)の場合、wrapper のtabIndexを自動的に設定しないようにし、二重タブストップ問題を解消する変更内容
typeproptype="description"(デフォルト): 従来通りaria-describedbyで補足説明として機能type="label": children にaria-labelledbyを付与し、ツールチップのメッセージがアクセシブルネームとして機能(アイコンのみのボタン等に有用)type="label"の場合はaria-describedbyは付与されない(ラベルであり説明であるのは不自然なため)type="label"の場合はariaDescribedbyTargetの指定は無視されるtabIndexの自動制御button,a[href],input,select,textarea,[tabindex])の場合、wrapper にtabIndexを設定しないtabIndex=0を設定tabIndexprop を明示的に指定した場合はその値が優先される(後方互換)テスト
Tooltip.test.tsxを新規作成し、tabIndex・type="description"・type="label"の各パターンをテスト。Storybook
typeprop 用のストーリーを追加。プロダクト側で対応が必要な事項
確認方法
https://63d0ccabb5d2dd29825524ab-iwqplfqzqm.chromatic.com/?path=/story/components-tooltip--type
Components/Tooltip>typeストーリーでlabel/descriptionの動作確認aria-labelledby/aria-describedbyの付与先を確認