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

fix(ModelessDialog): modeless dialog閉じたときのフォーカス処理修正 #5177

Merged

Conversation

daiHash
Copy link
Contributor

@daiHash daiHash commented Dec 6, 2024

関連URL

https://smarthr.atlassian.net/browse/SHRUI-1067

概要

ModelessDialogを閉じたときのフォーカスの処理が無いので、フォーカスをコンテンツに戻す処理を実装する

  • ModelessDialog以外の最終フォーカスした要素にフォーカスを戻す

変更内容

modeless dialogをボタンまたESCキーで閉じた際にmodeless dialog以外の最終フォーカスした要素にフォーカスを戻す

  • ModelessDialogを開いた際にフォーカスイベントを検知してフォーカスされている要素をrefで管理する
    • フォーカスがModelessDialog内の場合はフォーカスをrefに代入しない
  • onClickCloseとおnPressEscapeにmodeless dialog以外の最終フォーカスした要素にフォーカスを戻す処理を追加
Screen.Recording.2024-12-09.at.10.09.14.mov

確認方法

Storybook や Chromatic で確認してください。

Copy link

pkg-pr-new bot commented Dec 6, 2024

Open in Stackblitz

npm i https://pkg.pr.new/kufu/smarthr-ui@5177

commit: 1e64a72

@daiHash daiHash marked this pull request as ready for review December 9, 2024 01:06
@daiHash daiHash requested a review from a team as a code owner December 9, 2024 01:06
@daiHash daiHash requested review from misako0927 and s-sasaki-0529 and removed request for a team December 9, 2024 01:06
@daiHash daiHash removed the WIP label Dec 9, 2024
Copy link
Contributor

@s-sasaki-0529 s-sasaki-0529 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍️ Storybook にて、閉じるボタンまたはESCキーで閉じた際に、トリガーボタンの方にフォーカスがあたることを確認しました!

@daiHash daiHash merged commit 1590159 into master Dec 18, 2024
14 checks passed
@daiHash daiHash deleted the SHRUI-1067-handle-focus-after-close-for-modeless-dialog branch December 18, 2024 05:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants