-
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: Opening card modal sets wrong color on statusbar if swipeToClose is set to true #26173
Comments
Thanks for the report. Does this issue happen with |
I see the same behavior if i set I have made a new commit to reproduction repo with Step 1: App is started with StatusBar style set to DARK (Status bar is white on white) Step 2: Opens modal - StatusBar is white on black Step 3: Closes modal - Status bar is set to device style, not previous state Documentation |
Any good workaround or patch available in the meantime? |
I use this patch with patch-package:
|
Hello everyone, can you test with this dev-build and let me know if the problem persists? The dev-build caches the status bar style when the modal is presented and returns back to that value when the modal is dismissed.
For the provided reproduction:
This is the behavior I am seeing in the dev-build: Kapture.2022-11-10.at.19.05.48.mp4Note: Changes are on the |
There is another problem with setting the status bar color in the first place. Take for example https://ionicframework.com/docs/api/modal#mounting-inner-contents |
@realityfilter can you provide a reproduction or more about your setup? Ionic only sets the status bar style in very specific scenarios:
It shouldn't be applying for full screen modals without swipe to close. |
We are using swipeToClose. Because modals with canDismiss enabled but without an presentingElement can not be closed via swiping. |
@sean-perkins Thanks, the dev build seems to solve our problem. When it comes to Is the idea that all modals with a presenting element should be swipable, and all fullscreen modals should not? If this is the case, I agree with @realityfilter that there is a missing option to enable swipeToClose on fullscreen modals (if we are not to use |
@torgnywalin @realityfilter thank you both for your feedback around this issue. This status bar style override really should only ever applied to card modals, but one of our checks was off. With some discussion with the team we have corrected this. Here's an updated dev-build to test with, that shouldn't apply the status bar style overrides when using a fullscreen modal:
The intention of deprecating Your feedback surrounding canDismiss = (role: string) => {
return role === 'confirm' || role === 'cancel';
} <ion-modal [canDismiss]="canDismiss"></ion-modal> Optionally we could pass along |
@torgnywalin could you share the use case for wanting to disable swipe to close on a card modal? The API changes make sense to me, but I also want to tie that understanding to UI as well. |
Thank you very much for the explanation and the effort. Some background info. We are using vue and the modal code is handled in composable functions that abstract away the underlying framework. It is hard to access the presentingElement outside of components. That is why we happen to use fullscreen modals in the first place. Could the presentingElement not be derived from the framework itself? |
@sean-perkins I'm not sure if I have any good use cases. I think it's been with us from earlier versions. Since we programaticly open the modal with modalController, it was easier to just create the modal with swipeToClose: false and then have control of closing the modal in the modal component. The button click event did the checks and dismissed or alerted about why it can't dismiss, but I agree that that is not a great solution. So if role and even data is available in the canDismiss function that would work great for us. Also I have no issues with not being able to swipe to close a fullscreen modal. Thanks for explaining your thoughts about why this was done. |
@realityfilter thanks for the added detail. In those decoupled functions, is it possible to query the DOM to look-up the element you expect to be the presenting element? For example, this could be the nearest @torgnywalin I've logged that feature change here, if you would like to track it: #26292. The team has discussed this change and we want to resolve this pain point before removing I've also opened a PR to track the original issue with the status bar style here: #26291. That will be available in a weekly patch release, once the team has reviewed and approved it. Appreciate the positive discussion here. If you have ideas or pain points that you can provide context on, would love to discuss 👍 |
@realityfilter I think you can solve that by setting an id on ion-router-outlet as @sean-perkins describes. <ion-router-outlet id="main"></ion-router-outlet> let presentingElement;
const topModal = await modalController.getTop();
// We use topModal to stack modals if we open one modal from within another modal.
if (topModal) {
presentingElement = topModal;
} else {
presentingElement = document.getElementById('main');
}
const modal = await modalController.create({
presentingElement: presentingElement,
... // Rest of properties
}) I have not tested this exact code, but we do something very close to this when opening modal in our apps. @sean-perkins Thanks, would love to have a discussion about some ideas and pain points, but I would need to gather some more context around them, hope it's ok If I contact you at a later time |
@torgnywalin Thanks. That helps. I will try this. |
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
Opening a card modal with
swipeToClose: true
will change StatusBar style to the style of the device.Expected Behavior
I would expect that the behavior is the same regardless of what swipeToClose is set to.
And that if the modal is to change the statusbar it should be able to set it back to what is was set to before.
If keeping track is not possible I think there should be options for:
default
)Steps to Reproduce
To reproduce:
ionic cap run ios
)App.vue
(Statusbar is white on white)Code Reproduction URL
https://github.com/torgnywalin/issueModalStatusBar
Ionic Info
Additional Information
No response
The text was updated successfully, but these errors were encountered: