-
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: focus trapping activates on toast if non-toast presented first #24733
Comments
Thanks for the issue. Can you please reproduce this in an Ionic starter app and provide a link to the GitHub repo? |
Hi @liamdebeasi, i tried to reproduce the issue from a blank Ionic starter app. Sadly didn't to succed to reproduce it for the moment.
There might be a strange behaviour due to the complexity of my app. Thank you for your time ! |
I recommend isolating the issue in your application first. Remove pieces of code, and check to see if the issue still reproduces every time you do that. |
@liamdebeasi @Pictocube Actually same issue here. For 2 weeks, I have been trying to isolate the issue, but no luck. |
I am having the same issue, but only on Safari or Firefox. When a toast message is present, I cannot focus my form fields. I cannot reproduce this in a clean app. We did upgrade this app from Ionic 5 to 6 and upgraded Angular if that helps. |
You can see the bug in action here: https://hq.dev.lexgo.live/login in Safari or Firefox. Works fine in Chrome |
@tonymccallie @liamdebeasi what do you think about toast.removeAttribute('tabindex'); await toast.present();` |
I managed to reproduce this issue by showing |
@miljann995 can you try removing 'tabindex'? |
@papagei-ma Yes, removing |
@miljann995 you can see my comment before, I see. You mean, due to showing a loader while routing to the page in my case, that was reproducible. Yet when I refresh the page, which seems not show a loader, the focus was not possible :). Thanks, I think I can sleep now :D. |
@papagei-ma thank you! toast.removeAttribute('tabindex'); Worked for me. |
Thanks, I can reproduce this. We have a focus trapping utility that prevents focus from going outside of elements such as modals and alerts for accessibility purposes. Focus trapping should not happen on |
@liamdebeasi Do you think removing tabindex is ok? |
Removing tabindex means that users will be able to tab to the |
@liamdebeasi oh, thank you. |
Can everyone try the following dev build and let me know if it resolves the issue?
This applies to all Angular, React, Vue, and Core packages. Example:
|
@liamdebeasi That version did resolve the issue for me. It works without having to remove tabindex. |
@liamdebeasi Bug doesn't occur anymore with the |
@liamdebeasi same for me, the issue seems to be resolved with your fix 👏 🚀 |
Thanks for the issue. This has been resolved via #24816, and a fix will be available in an upcoming release of Ionic Framework. |
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
Ionic Framework Version
Current Behavior
Since Ionic-6 when a ion-toast is displayed, it steal the focus from the ion-input who was initially focused.
After the toast is dismissed, my ion-input still owns the focus (the CSS property “has-focus” is correctly triggered), but the caret inside the input is missing.
<ion-input _ngcontent-upn-c145="" hidekeyboard="" type="text" required="" ng-reflect-type="text" ng-reflect-required="" ng-reflect-placeholder="Emplacement ?" class="sc-ion-input-md-h sc-ion-input-md-s md hydrated has-focus"> <input class="native-input sc-ion-input-md" autocapitalize="off" autocomplete="off" autocorrect="off" name="ion-input-2" placeholder="Emplacement ?" required="" spellcheck="false" type="text"> </ion-input>
Then I'm unable to whrite inside my input without re-select it.
Expected Behavior
I'm exepected to be able to whrite inside my ion-input while the ion-toast is displayed and keeping the focus after the toast is dissmissed.
Steps to Reproduce
Create a page with a single input and click on it to focus it.
With a timeout for exemple create a simple ion-toast and present it.
const toast = await this.toastController.create({ message: 'This is a test', duration: 2000 });
toast.present();
Try to whrite something while the ion-toast is displayed (or after it's dissmissed) without clicking on the input.
Code Reproduction URL
No response
Ionic Info
Ionic:
Ionic CLI : 6.18.1
Ionic Framework : @ionic/angular 6.0.5
@angular-devkit/build-angular : 13.2.2
@angular-devkit/schematics : 13.2.2
@angular/cli : 13.2.2
@ionic/angular-toolkit : 6.0.0
Cordova:
Cordova CLI : 9.0.0 ([email protected])
Cordova Platforms : none
Cordova Plugins : no whitelisted plugins
Utility:
cordova-res : not installed globally
native-run : 1.5.0
System:
Android SDK Tools : 26.1.1
NodeJS : v16.13.2
npm : 8.2.0
OS : Windows 10
Additional Information
Apparently, this a bug due to tabindex valued to
-1
in the ion-toastMore details here : https://forum.ionicframework.com/t/ionic-version-6-angular-toast-now-holds-focus-preventing-inputs-from-being-used/218430/5
The text was updated successfully, but these errors were encountered: