Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
Timbuktu1982 opened this issue Apr 11, 2025 · 12 comments
Open

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

Timbuktu1982 opened this issue Apr 11, 2025 · 12 comments

Comments

@Timbuktu1982
Copy link

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

@asyncLiz
Copy link
Collaborator

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();

@Timbuktu1982
Copy link
Author

Hi Liz,

unfortunately your example does not work either.

Image

I have also published this problem in a fork repo (treeder/material#35 (comment)).
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?

@asyncLiz
Copy link
Collaborator

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

@Timbuktu1982
Copy link
Author

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?

@HarmfulBreeze
Copy link

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 :)

@asyncLiz
Copy link
Collaborator

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 asyncLiz changed the title Textfield with type="date" not working correctly in chrome Textfield with type="date" shows extra calendar icon in Firefox Apr 15, 2025
@Timbuktu1982
Copy link
Author

Timbuktu1982 commented Apr 16, 2025

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
Copy link
Author

@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).

@HarmfulBreeze
Copy link

@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?

@Timbuktu1982
Copy link
Author

Ah ok, now i understand.

But why was this removed intentionally?

@asyncLiz
Copy link
Collaborator

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.

@Timbuktu1982
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants