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

UIQM-728 Keep focus on last focused element when user cancels on confirmation modals. #767

Merged
merged 3 commits into from
Dec 16, 2024

Conversation

BogdanDenis
Copy link
Contributor

Description

When a user chooses "Cancel" option on any of the confirmation modals they should have focus on the last focused element before the modal opened.

Screenshots

chrome_KFrvuuzME3.mp4

Issues

UIQM-728

@BogdanDenis BogdanDenis requested review from Dmytro-Melnyshyn and a team December 10, 2024 12:50
Copy link

github-actions bot commented Dec 10, 2024

Jest Unit Test Results

  1 files  ±0   45 suites  ±0   2m 35s ⏱️ ±0s
483 tests +1  483 ✅ +1  0 💤 ±0  0 ❌ ±0 
486 runs  +1  486 ✅ +1  0 💤 ±0  0 ❌ ±0 

Results for commit e81c774. ± Comparison against base commit 72df744.

♻️ This comment has been updated with latest results.

Comment on lines 481 to 483
setTimeout(() => {
focusLastFocusedInput();
});
Copy link
Contributor

Choose a reason for hiding this comment

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

  1. It looks like there is a need to close a modal first and then invoke the focusLastFocusedInput. Is it possible?
  2. Where should the focus be after a field is linked/unlinked?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I guess remove linking is not applicable for current story if it only happens instantly when a record has been opened for deriving. I'll remove this code because it's not needed.
But generally a modal will close first, and a last focused element will be re-focused second:

chrome_88Sf3gA0LK.mp4

Copy link
Contributor

Choose a reason for hiding this comment

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

But generally a modal will close first, and a last focused element will be re-focused second:

I meant setTimeout is used to trigger the focus after modal is closed (state is false) and whether it is possible to do it without setTimeout, just wait until modal state changes to false, but I think it will require a lot more changes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Dmytro-Melnyshyn oh I see. it's not because we're waiting for the modal to close, but we need the form to finish all updates. If we set focus right away it'll be gone when the form updates. And there's no way to know when it does so we have to use setTimeout here

@Dmytro-Melnyshyn Dmytro-Melnyshyn requested review from a team and removed request for a team December 12, 2024 12:53
@BogdanDenis BogdanDenis merged commit aabd8a3 into master Dec 16, 2024
15 checks passed
@BogdanDenis BogdanDenis deleted the UIQM-728 branch December 16, 2024 14:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants