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

bug: Cannot focus any element inside of IonModal while IonMenu is open. #24361

Closed
4 of 6 tasks
Cyral opened this issue Dec 10, 2021 · 9 comments · Fixed by #24611
Closed
4 of 6 tasks

bug: Cannot focus any element inside of IonModal while IonMenu is open. #24361

Cyral opened this issue Dec 10, 2021 · 9 comments · Fixed by #24611
Labels
package: core @ionic/core package type: bug a confirmed bug report

Comments

@Cyral
Copy link

Cyral commented Dec 10, 2021

Prerequisites

Ionic Framework Version

  • v4.x
  • v5.x
  • v6.x

Current Behavior

Elements inside an IonModal should be focusable (and editable) at all times. When an IonMenu is open in the background, the focus gets trapped inside of the menu and input elements inside the modal cannot be used.

Screen.Recording.2021-12-09.at.9.10.33.PM.mov

Expected Behavior

Elements inside an IonModal cannot be focused (meaning inputs cannot be typed in) if an IonMenu is open (behind the modal).

Steps to Reproduce

Create an IonMenu with a button that launches an IonModal. Both the menu and the modal should have an input element. If the menu has no inputs, the bug doesn't seem to occur.

Code Reproduction URL

https://github.com/Cyral/ionic-24361

Ionic Info

Ionic 5.9.2 w/ React

No response

Additional Information

The input element inside the IonModal receives a focus event, but it is quickly blurred and the last descendant of the IonMenu is then focused. The stack trace from adding a focus event handler tot he last menu descendant is:

t.focusLastDescendant	@	ion-menu_3.entry.js:1
t.trapKeyboardFocus	@	ion-menu_3.entry.js:1
handleFocus	@	ion-menu_3.entry.js:1

I believe this commit introduced in 5.8.5 is the issue: bdb268a Reverting to 5.8.4 fixes the issue

@ionitron-bot ionitron-bot bot added the triage label Dec 10, 2021
@liamdebeasi
Copy link
Contributor

Thanks for the issue. Can you provide some more context as to why the menu needs to stay open when the modal is also visible in this scenario? I would like to understand the use case before we make any potential changes.

In general, focus should remain trapped inside of a menu when it is open to keep the experience accessible, which is why the focus is not being moved to the modal.

@liamdebeasi liamdebeasi added the needs: reply the issue needs a response from the user label Dec 10, 2021
@ionitron-bot ionitron-bot bot removed the triage label Dec 10, 2021
@Cyral
Copy link
Author

Cyral commented Dec 13, 2021

Thanks for the issue. Can you provide some more context as to why the menu needs to stay open when the modal is also visible in this scenario? I would like to understand the use case before we make any potential changes.

In general, focus should remain trapped inside of a menu when it is open to keep the experience accessible, which is why the focus is not being moved to the modal.

In my app, the menu has various controls (including inputs) to filter items in a list. These filters can also be saved by the user, and later edited. If the user edits a filter, the menu should not close otherwise they will lose their place after closing the modal.

In any case, the focus should be trapped in the menu or modal that is on top of all other content.

@ionitron-bot ionitron-bot bot added triage and removed needs: reply the issue needs a response from the user labels Dec 13, 2021
@Cyral
Copy link
Author

Cyral commented Dec 13, 2021

RPReplay_Final1639414774.MP4

Here is a video of the UI in action, I have reverted to a previous version of Ionic until this is fixed since it broke the filter editing dialog.

@liamdebeasi liamdebeasi added package: core @ionic/core package type: bug a confirmed bug report labels Dec 14, 2021
@ionitron-bot ionitron-bot bot removed the triage label Dec 14, 2021
@hoangnv2nf
Copy link

I have same issue in Ionic v6.
image

@liamdebeasi
Copy link
Contributor

Thanks for the issue. Can everyone try the following dev build and let me know if it resolves the issue?

Angular

npm install @ionic/[email protected]

React

npm install @ionic/[email protected] @ionic/[email protected]

Vue

npm install @ionic/[email protected] @ionic/[email protected]

Stencil/Vanilla JavaScript

npm install @ionic/[email protected]

@Cyral
Copy link
Author

Cyral commented Jan 20, 2022

@liamdebeasi Thank you, it resolves it for me.

@Cyral Cyral closed this as completed Jan 20, 2022
@liamdebeasi
Copy link
Contributor

Great! I am going to keep this issue open until #24611 is merged. Thanks for testing!

@liamdebeasi
Copy link
Contributor

Thanks for the issue. This has been resolved via #24611, and a fix will be available in an upcoming release of Ionic Framework.

@ionitron-bot
Copy link

ionitron-bot bot commented Feb 24, 2022

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.

@ionitron-bot ionitron-bot bot locked and limited conversation to collaborators Feb 24, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
package: core @ionic/core package type: bug a confirmed bug report
Projects
None yet
3 participants