Skip to content

Commit 42e4420

Browse files
Merge pull request #267 from balena-io-modules/fix-date-time-safari-input
Fix empty dateTime input behaviour
2 parents 9945aea + 9c0388d commit 42e4420

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

src/theme.tsx

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -196,27 +196,31 @@ const calendarDataUrl = `url("data:image/svg+xml;utf8,${encodeURIComponent(
196196
// Fix placeholder text for date inputs in Safari: https://github.com/mui/material-ui/issues/37226
197197
const safariEmptyDateBugFix = {
198198
'@supports (font: -apple-system-body) and (-webkit-appearance: none)': {
199-
'&:has(input[type="date"]):not([value]), &:has(input[type="datetime-local"]):not([value])':
199+
'&:has(input[type="date"][value=""]):not(:focus-within), &:has(input[type="datetime-local"][value=""]):not(:focus-within)':
200200
{
201201
color: 'rgba(0,0,0,0)',
202202
position: 'relative',
203203
minWidth: 120,
204204
},
205-
'&:has(input[type="date"]):not([value])::before': {
205+
206+
'&:has(input[type="date"][value=""]):not(:focus-within)::before': {
206207
content: '"dd / mm / yyyy"',
207208
left: 16,
208209
color: '#333',
209210
display: 'inline-block',
210211
position: 'absolute',
211212
},
212-
'&:has(input[type="datetime-local"]):not([value])::before': {
213-
content: '"dd / mm / yyyy, --:--"',
214-
left: 16,
215-
color: '#333',
216-
display: 'inline-block',
217-
position: 'absolute',
218-
},
219-
'&:has(input[type="date"]):not([value])::after, &:has(input[type="datetime-local"]):not([value])::after':
213+
214+
'&:has(input[type="datetime-local"][value=""]):not(:focus-within)::before':
215+
{
216+
content: '"dd / mm / yyyy, --:--"',
217+
left: 16,
218+
color: '#333',
219+
display: 'inline-block',
220+
position: 'absolute',
221+
},
222+
223+
'&:has(input[type="date"])::after, &:has(input[type="datetime-local"])::after':
220224
{
221225
content: '""',
222226
position: 'absolute',

0 commit comments

Comments
 (0)