Repository navigation
Description
Prerequisites
- I have read the Contributing Guidelines.
- I agree to follow the Code of Conduct.
- I have searched for existing issues that already report this problem, without success.
Ionic Framework Version
v7.x
Current Behavior
When using other components that utilize the Angular CDK or similar methods to present content in an overlay (for example, a select, date, or color picker) within an Ionic modal, this overlay is affected by the Ionic modal's focus. This seems to be related to the class: "ion-disable-focus-trap".
Is there a way to disable this requirement when starting an Ionic modal via a declarative element or via ModalController?
I found a post on Ionic Forum: https://forum.ionicframework.com/t/work-around-for-ionic-modal-focus-trapping/216633/6 where a user described a similar issue and other user sugested a hack:
Copy code
<ion-modal #myModal>
<ng-template>
<ion-content>
<mbsc-datepicker
(onOpen)="myModal.cssClass = 'ion-disable-focus-trap'"
(onClose)="myModal.cssClass = ''">
</mbsc-datepicker>
</ion-content>
</ng-template>
</ion-modal>
This helps, but not gracefully, as this code has to be duplicated in all Ionic modals where there are other components that utilize the Angular CDK overlays or similar.
Using ModalController and passing a function to the component, something similar to this would be necessary:
onOpen(open: any) {
this.ModalController.getTop().then(modal => modal?.classList.toggle('ion-disable-focus-trap', open));
}
Expected Behavior
Let user define the modal focus behavior or disable focus trap it not currently necessary ionic framework.
Steps to Reproduce
- clone the testing repo
- npm install
- ionic serve
- open the modal
- try to interact with the select components
Code Reproduction URL
Ionic Info
Ionic:
Ionic CLI : 7.1.5
Ionic Framework : @ionic/angular 7.7.2
@angular-devkit/build-angular : 17.1.3
@angular-devkit/schematics : 17.1.3
@angular/cli : 17.1.3
@ionic/angular-toolkit : 9.0.0
Capacitor:
Capacitor CLI : 5.5.1
@capacitor/android : not installed
@capacitor/core : not installed
@capacitor/ios : not installed
Utility:
cordova-res : not installed globally
native-run : 1.7.4
System:
NodeJS : v20.10.0 (C:\Program Files\nodejs\node.exe)
npm : 10.2.3
OS : Windows 10
Additional Information
No response

Activity
mapsandapps commentedon Feb 14, 2024
Thank you for submitting this issue. I'm going to close this, as it sounds like this is a duplicate of #24646
ionitron-bot commentedon Mar 15, 2024
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.