-
Notifications
You must be signed in to change notification settings - Fork 13.5k
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
bug: ionic should not re-focus an element when focus already moved on overlay dismiss by developer #28849
Comments
Thanks, I think this makes sense to have. However, you can provide a reproduction case so I can test your PR? |
No problem! https://github.com/aeharding/test-focus |
Thanks! This request makes sense. Ionic tries to focus an element inside of the previous view. However, if focus is already in the previous view then we shouldn't attempt to move focus. |
…ocus manually (#28850) Issue number: resolves #28849 --------- ## What is the current behavior? If the developer tries to set focus to a custom element on overlay dismissal, Ionic will always override that focus. ## What is the new behavior? - If focus is already set by developer during dismissal, then Ionic will not restore focus to previous element ## Does this introduce a breaking change? - [ ] Yes - [x] No ## Other information In the before video, you can see the text box is focused by developer code when "Mention User" is tapped, which opens the keyboard. Shortly after that, when the bottom sheet fully dismisses, Ionic focuses the button, removing focus from the text box and hiding the keyboard. In the after, Ionic detects that the developer has already focused the text box and does not change that focus. |Before|After| |---|---| |<video src="https://github.com/ionic-team/ionic-framework/assets/2166114/47d55eff-29af-4019-ac3c-00f9fe722ca7"></video>| <video src="https://github.com/ionic-team/ionic-framework/assets/2166114/508ae466-d037-41eb-b518-92338a122b22"></video>|
This was fixed in #28850. Thanks again for making the PR! |
Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out. |
Prerequisites
Describe the Feature Request
Allow developer to set custom focus during overlay dismissal.
Describe the Use Case
In the
handler
of anion-action-sheet
the developer may want to restore focus to a custom element, like a text box.Describe Preferred Solution
Ionic overlay should detect whether focus has been set by developer, and not restore focus if that is so.
Describe Alternatives
None.
Reproduction
https://github.com/aeharding/test-focus
Additional Information
Not sure if this is considered a feature or a bug 😅
The text was updated successfully, but these errors were encountered: