ng-clarity
ng-clarity copied to clipboard
Focus should return to previously active element after closing modal
Describe the bug
After closing clarity modal, the previously active element is not focused.
How to reproduce
https://clarity-v3-light-theme-focus-element.stackblitz.io/
Steps to reproduce the behavior:
Use keyboard to navigate to button "foo". Hit "Enter" to open modal. Hit "Escape" to close the modal.
Expected behavior
The button "foo" should be focused.
Additional notes
It should be fixable in focus-trap.directive.ts since it is already doing so, but it sets previousActiveElement wrong. In AfterViewInit it is set to the element inside focusTrap, it will be fixed if it is set to document.activeElement before AfterViewInit (in onInit maybe?).
See https://github.com/vmware/clarity/issues/5668
+1.. We have a scroll at a body level and focus does not return back to the element that trigerred the modal since body scroll is removed when the modal is open. Extending no-scrolling to set overflow:auto doesnt fix the issue .
This was fixed in https://github.com/vmware-clarity/ng-clarity/pull/455.
Hi there 👋, this is an automated message. To help Clarity keep track of discussions, we automatically lock closed issues after 14 days. Please look for another open issue or open a new issue with updated details and reference this one as necessary.