mui / mui/material-ui

[TextField] Placeholder doesn't differ from filled value on Safari when `type="date"`

Open
#31,305 9 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

has workaround scope: text field type: bug waiting for 👍
Dominant language
JavaScript
Stars
99.1k
Forks
32.5k
Avg merge
2d 17h
Merged PRs (30d)
106

Description

Duplicates
  • I have searched the existing issues
Latest version
  • I have tested the latest version
Current behavior 😯

This bug is only happened in Safari.
If I set type="date" the text color remains black even though I am not typing.

<InputBase id="greeting" type="date" />
ss
Expected behavior 🤔

When I am not typing, the text color should be grey like the below image.

ss

I know this is because of styling problem. Adding below sx props works good for me.

<InputBase id="greeting" type="date"
	sx={{
		"& .MuiInputBase-input": {
			backgroundColor: "white",
		},
	}}
/>
Steps to reproduce 🕹

Steps:

  1. add type="date"`` to <InputBase />
  2. run the application on Safari
Context 🔦

This behavior causes confusion as to whether the user actually inputed the value or not.
It should be grey color if users don't input the values.

I know MUI DatePicker is great, but this time I have to use TextField for date. so I'm so happy to fix this problem.

Your environment 🌎
`npx @mui/envinfo`
  System:
    OS: macOS 11.6
  Binaries:
    Node: 16.13.0 - ~/.volta/tools/image/node/16.13.0/bin/node
    Yarn: 1.22.17 - ~/.volta/tools/image/yarn/1.22.17/bin/yarn
    npm: 8.1.0 - ~/.volta/tools/image/node/16.13.0/bin/npm
  Browsers:
    Chrome: 98.0.4758.109
    Edge: Not Found
    Firefox: 97.0.1
    Safari: 15.0
  npmPackages:
    @emotion/react: 11.8.1 => 11.8.1 
    @emotion/styled: 11.8.1 => 11.8.1 
    @mui/base:  5.0.0-alpha.69 
    @mui/icons-material: 5.4.2 => 5.4.2 
    @mui/lab: 5.0.0-alpha.70 => 5.0.0-alpha.70 
    @mui/material: 5.4.3 => 5.4.3 
    @mui/private-theming:  5.4.2 
    @mui/styled-engine:  5.4.2 
    @mui/styles: 5.4.2 => 5.4.2 
    @mui/system:  5.4.3 
    @mui/types:  7.1.2 
    @mui/utils:  5.4.2 
    @types/react: 17.0.39 => 17.0.39 
    react: 17.0.2 => 17.0.2 
    react-dom: 17.0.2 => 17.0.2 
    typescript: 4.5.5 => 4.5.5 

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the reported behavior in Safari 15 with the InputBase example using type="date", then inspect the component's input styling and the effect of the suggested sx override. Done means an unfilled date input uses the expected grey text color in Safari without requiring consumer-provided sx styling.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, react
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.