material-web icon indicating copy to clipboard operation
material-web copied to clipboard

Textfield with type="date" shows extra calendar icon in Firefox

Open Timbuktu1982 opened this issue 7 months ago • 13 comments

What is affected?

Component

Description

Hi there,

when i used a textfield with type="date" it working correctly in firefox, but not working correctly in chrome or edge. I miss the date-picker from browser...

Can you help me?

Reproduction

Use a simple is working in firefox, but not in chrome or edge (date-picker from browser is missing).

Workaround

no content

Is this a regression?

No or unsure. This never worked, or I haven't tried before.

Affected versions

2.3.0

Browser/OS/Node environment

Chrome: 134.0.6998.117 (not working) Edge 112.0.1722.48 (not working) Firefox: 137.0.1 (working) OS: Ubuntu 24.10 Node: 22.12.0 NPM: 10.9.0

Timbuktu1982 avatar Apr 11 '25 07:04 Timbuktu1982

It appears to be working for me in Chrome: https://jsbin.com/rowowusafu/edit?html,output

Image

Can you provide more info on what isn't working? You can show the picker by focusing the field and pressing the space key.

You can also add an icon button that calls showPicker() when it's clicked.

// This method was just recently added, it's not published yet
// textfield.showPicker(); 
// You can use the shadow root in the meantime
textfield.shadowRoot.querySelector('input').showPicker();

asyncliz avatar Apr 11 '25 15:04 asyncliz

Hi Liz,

unfortunately your example does not work either.

Image

I have also published this problem in a fork repo (https://github.com/treeder/material/issues/35#issuecomment-2797463422). Treeder has a good approach, but unfortunately the solution given doesn't work for me either. I have changed the Chrome display settings to the light theme, but the date picker is still not there.

Have you another idea?

Timbuktu1982 avatar Apr 14 '25 06:04 Timbuktu1982

Are you referring to the browser's <input> calendar icon that is intentionally removed?

Image

The datepicker itself still works, but in MWC the non-Material browser <input> icons are removed in favor of using Material icon buttons. Here's a demo: https://output.jsbin.com/wayuwolabu

Image

asyncliz avatar Apr 14 '25 15:04 asyncliz

Hi Liz,

unfortunately your example does not work properly (I see an unspecified error in the console). Image

But I have a fundamental problem with this solution. In Firefox I see two icons (the original datepicker icon and the trailing icon - I had already thought of this solution a few days ago, but discarded it due to this circumstance). Image

Is there a way to deactivate the date picker in general and only display the trailing icon?

Timbuktu1982 avatar Apr 15 '25 06:04 Timbuktu1982

Date picker not opening in JS Bin might be due to this (it's about <select> but it also applies to <input>, at least on Edge).

About the calendar picker indicator on Firefox, you might want to follow bug #1812397 and the related bugs mentioned at the end of the thread :)

HarmfulBreeze avatar Apr 15 '25 13:04 HarmfulBreeze

Date picker not opening in JS Bin might be due to this

Yes, that's why I linked to the output.jsbin.com, but outputs are only available for a short amount of time before it reverts to the edit page. You can copy/paste the same code into a new jsbin, open the external output page, and then it'll work like it normally does.

About the calendar picker indicator on Firefox, you might want to follow bug #1812397 and the related bugs mentioned at the end of the thread :)

Thanks for the links! Let's repurpose this issue to track hiding Firefox's new <input type="date"> icon once there's a CSS selector to style it.

asyncliz avatar Apr 15 '25 15:04 asyncliz

Hi,

thank you for your replies.

I have not found a general solution for Firefox, but it gives a possibility to make the icon transparent. The solution is compatible with most browsers (https://caniuse.com/mdn-css_properties_-webkit-text-fill-color).

input { -webkit-text-fill-color: black; color: transparent; }

Now i have the problem, how i can set this style for the input elements inside the shadow of md-outlined-text-field. Have you an idea?

The only thing that surprises me is the fact that the repo of https://github.com/treeder/material has no problem with this issue. There the date-picker also works in chrome.

Timbuktu1982 avatar Apr 16 '25 09:04 Timbuktu1982

@asyncLiz The new title irritates me a little. I continue to have the basic problem with the missing default calendar picker icon in Chrome and Edge (latest versions).

Timbuktu1982 avatar Apr 16 '25 10:04 Timbuktu1982

@asyncLiz The new title irritates me a little. I continue to have the basic problem with the missing default calendar picker icon in Chrome and Edge (latest versions).

I believe this is what Liz said was intentionally removed:

Are you referring to the browser's calendar icon that is intentionally removed?

HarmfulBreeze avatar Apr 16 '25 12:04 HarmfulBreeze

Ah ok, now i understand.

But why was this removed intentionally?

Timbuktu1982 avatar Apr 16 '25 12:04 Timbuktu1982

The browser calendar icons are removed because they don't match the Material Design spec.

In Material, the text field's icon should be interactive, show a ripple and focus ring, and match the new updated icon symbols. The browser input icons are intentionally removed so they don't clash with Material icons that are intended to be the replacement.

If this doesn't work for you, you can always create use the "field" building block component to create a text field that doesn't remove built-in browser calendar icons.

asyncliz avatar Apr 21 '25 23:04 asyncliz

Hi Liz, sorry, i didn't ask my question correctly. Why the icon is only removed in chrome by default and not in firefox?

Timbuktu1982 avatar Apr 28 '25 06:04 Timbuktu1982

Why the icon is only removed in chrome by default and not in firefox?

That is what I re-purposed this bug for. There should not be a calendar icon in Firefox. Once the Firefox bug for an icon pseudo selector is implemented, we can add that selector to the text field's styles to remove the icon from both Chrome and Firefox:

https://github.com/material-components/material-web/blob/5bc15069d136c51e912137dcba1b212a106bb1dd/textfield/internal/_input.scss#L30-L33

asyncliz avatar Apr 28 '25 18:04 asyncliz