You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
bug: modal text color is set incorrectly when app and system dark mode settings aren't the same #26060
Hello! I'm still trying to isolate the cause of this, but I wanted to give a quick update. The issue seems to be specific to ion-modal, and also shows with components other than ion-datetime. (For example, a random ion-text placed underneath the datetime also exhibits the incorrect text color.)
As a workaround, you could use ion-popover instead of ion-modal; I haven't been able to replicate the issue that way.
It looks like the issue here comes down to ion-modal overwriting the text color with --ion-color-primary-contrast when it shouldn't, or not overwriting it with --ion-text-color when it should. Normal modals don't show this problem because wrapping the modal content with an ion-content sets the text color to what it should be, but including an ion-content isn't the intended usage with ion-datetime-button.
We should probably move some of the text color responsibility out of ion-content so it isn't required for situations like this.
There are a few possible workarounds here:
Manually set the color CSS property on either the ion-modal or the ion-datetime, updating the value depending on whether dark mode is toggled or not.
Keep the app's dark mode setting in sync with the device's by leveraging the prefers-color-scheme media query from the default variables.scss, rather than commenting that block out.
Use ion-popover instead of ion-modal, as mentioned previously.
changed the title [-]bug: CSS dark and light, datetime and picker[/-][+]bug: modal text color is set incorrectly when app and system dark mode settings aren't the same[/+]on Oct 21, 2022
I think I'm getting this issue when I first open an ion-datetime in calendar view on Android and also in Chrome.
If I open the calendar and then close and reopen then the dates are in black if I use this in my global.scss but it does not fix the first open:
ion-datetime {
Activity
Marius-Romanus commentedon Oct 17, 2022
Hello @liamdebeasi, I just wanted to know if you are looking at this, or if I make a solution in my project. Thank you!
liamdebeasi commentedon Oct 17, 2022
Hey there, apologies for the delay. Yes we will look at this soon.
averyrousseau commentedon Oct 20, 2022
Hello! I'm still trying to isolate the cause of this, but I wanted to give a quick update. The issue seems to be specific to
ion-modal, and also shows with components other thanion-datetime. (For example, a randomion-textplaced underneath the datetime also exhibits the incorrect text color.)As a workaround, you could use
ion-popoverinstead ofion-modal; I haven't been able to replicate the issue that way.averyrousseau commentedon Oct 21, 2022
It looks like the issue here comes down to
ion-modaloverwriting the text color with--ion-color-primary-contrastwhen it shouldn't, or not overwriting it with--ion-text-colorwhen it should. Normal modals don't show this problem because wrapping the modal content with anion-contentsets the text color to what it should be, but including anion-contentisn't the intended usage withion-datetime-button.We should probably move some of the text color responsibility out of
ion-contentso it isn't required for situations like this.There are a few possible workarounds here:
colorCSS property on either theion-modalor theion-datetime, updating the value depending on whether dark mode is toggled or not.prefers-color-schememedia query from the defaultvariables.scss, rather than commenting that block out.ion-popoverinstead ofion-modal, as mentioned previously.[-]bug: CSS dark and light, datetime and picker[/-][+]bug: modal text color is set incorrectly when app and system dark mode settings aren't the same[/+]riderx commentedon Dec 19, 2022
How to override any ionic element with ease
I had the same problem, the shadow dom was killing my vibe.
Because ionic elements are not always present, so even patch them in JS is not easy.
I found a beautiful and horrible solution in same time:
Todo
add this in your global css to detect components addition in the dom
Then add to your datetime the class
shadow-overrideNow add where you need the detection and the patch:
My issue was the day-active::after was white and my text was white also, no clue why, impossible to use a part for that.
It's inspired by http://www.backalleycoder.com/2012/04/25/i-want-a-damnodeinserted/
Took me 2 hours, I hate shadow dom as much as I like it.
Bonus
if you like to have the datetime button be only a date or time button, add this to the watcher:
And add to ion-datetime-button this:
class="shadow-override no-time"to remove button for time pickerclass="shadow-override no-date"to remove button date pickeriAbhinav commentedon Feb 1, 2023
This is similarly happening with me, exclusively on chrome.
Some components are not rendering correctly in dark mode on chrome, though they are working fine in safari.
madmacc commentedon Feb 13, 2023
I think I'm getting this issue when I first open an ion-datetime in calendar view on Android and also in Chrome.
If I open the calendar and then close and reopen then the dates are in black if I use this in my global.scss but it does not fix the first open:
ion-datetime {
&:not(.datetime-placeholder) {
color: black;
}
}
madmacc commentedon Feb 13, 2023
This did not work for me.
riderx commentedon Feb 13, 2023
@madmacc are you sure you include the css in root ?
on my side, I did remove all from ionic, shadow dom is more a pain than a gain.
I use now https://konstaui.com/ who is less powerful, but just a simple tailwindcss theme
fix(modal): set default text color (#27207)
thetaPC commentedon Apr 24, 2023
Thanks for the issue! This has been resolved via #27207 and will be available in an upcoming release of Ionic.
thetaPC commentedon Apr 26, 2023
The fix has been released in v7.0.4.