Skip to content

Commit 3d20959

Browse files
authored
fix(datetime): showing calendar grid no longer causes month to switch on ios 15 (#24554)
resolves #24405
1 parent 88602a9 commit 3d20959

File tree

1 file changed

+40
-15
lines changed

1 file changed

+40
-15
lines changed

core/src/components/datetime/datetime.scss

Lines changed: 40 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -79,24 +79,49 @@
7979
* unhiding the calendar content.
8080
* To workaround this, we set the opacity
8181
* of the content to 0 and hide it offscreen.
82-
* TODO: This is fixed in Safari 15+, so remove
83-
* when Safari 14 support is dropped.
82+
*
83+
* -webkit-named-image is something only WebKit supports
84+
* so we use this to detect general WebKit support.
85+
* aspect-ratio is only supported in Safari 15+
86+
* so by checking lack of aspect-ratio support, we know
87+
* that we are in a pre-Safari 15 browser.
88+
*
89+
* TODO(FW-554): Remove when iOS 14 support is dropped.
8490
*/
85-
:host(.show-month-and-year) .calendar-next-prev,
86-
:host(.show-month-and-year) .calendar-days-of-week,
87-
:host(.show-month-and-year) .calendar-body,
88-
:host(.show-month-and-year) .datetime-time {
89-
@include position(null, null, null, -99999px);
91+
@supports (background: -webkit-named-image(apple-pay-logo-black)) and (not (aspect-ratio: 1/1)) {
92+
:host(.show-month-and-year) .calendar-next-prev,
93+
:host(.show-month-and-year) .calendar-days-of-week,
94+
:host(.show-month-and-year) .calendar-body,
95+
:host(.show-month-and-year) .datetime-time {
96+
@include position(null, null, null, -99999px);
9097

91-
position: absolute;
98+
position: absolute;
9299

93-
/**
94-
* Use visibility instead of
95-
* opacity to ensure element
96-
* cannot receive focus
97-
*/
98-
visibility: hidden;
99-
pointer-events: none;
100+
/**
101+
* Use visibility instead of
102+
* opacity to ensure element
103+
* cannot receive focus
104+
*/
105+
visibility: hidden;
106+
pointer-events: none;
107+
}
108+
}
109+
110+
/**
111+
* This support check two cases:
112+
* 1. A WebKit browser that supports aspect-ratio (Safari 15+)
113+
* 2. Any non-WebKit browser.
114+
* Note that just overriding this display: none is not
115+
* sufficient to resolve the issue mentioned above, which
116+
* is why we do another set of @supports checks.
117+
*/
118+
@supports (not (background: -webkit-named-image(apple-pay-logo-black))) or ((background: -webkit-named-image(apple-pay-logo-black)) and (aspect-ratio: 1/1)) {
119+
:host(.show-month-and-year) .calendar-next-prev,
120+
:host(.show-month-and-year) .calendar-days-of-week,
121+
:host(.show-month-and-year) .calendar-body,
122+
:host(.show-month-and-year) .datetime-time {
123+
display: none;
124+
}
100125
}
101126

102127
:host(.datetime-readonly),

0 commit comments

Comments
 (0)