question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[TextField] type="time" does not render 00 seconds

See original GitHub issue

Duplicates

  • I have searched the existing issues

Latest version

  • I have tested the latest version

Current behavior 😯

When a value of ‘00:00:00’ is passed to <TextField type='time'/>, the seconds are not rendered.

The seconds are rendered for ‘00:00:01’

Expected behavior 🤔

Seconds selector is rendered for <TextField type=‘time’ value={‘00:00:00’}/>

Steps to reproduce 🕹

Steps:

  1. Import TextField component
  2. Render TextFieldwith props: value=‘00:00:00’, type=‘time’
  3. Observe that the TextFieldwith picker is not rendered

code sand box: https://codesandbox.io/s/mui-time-textfield-pg2pqn?file=/src/App.js

Context 🔦

I am creating an application to manage GTFS data. The specification requires that stop times be given in the form hh:mm:ss In one of the forms I would like the starting value for the stop time to be 00:00:00. The TextField component does not render the seconds part of the string. What makes matters worse is that when a value is selected the value changes to hh:mm, which does not conform to the GTFS specification.

Your environment 🌎

`npx @mui/envinfo`
  Don't forget to mention which browser you used.
  Output from `npx @mui/envinfo` goes here.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:8 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
hbjORbjcommented, Mar 29, 2022

@abhinav-22-tech

Hey, sure, no problem 👍

0reactions
hbjORbjcommented, Apr 20, 2022

For the date/time input types, step is expressed in seconds, with the default step being 60 seconds. The step scale factor is 1000 (which converts the seconds to milliseconds, as used in other algorithms).

Ref: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#attr-step

Yes, it indeed doesn’t seem like a bug.

InputProps: Attributes applied to the input element.

In the API doc of TextField, we provide the link for the possible attributes of the input element, so I think this was more of a support question in fact. I added the relevant label.

Here is a working solution: https://codesandbox.io/s/mui-time-textfield-forked-01dk6i?file=/src/App.js

Read more comments on GitHub >

github_iconTop Results From Across the Web

Remove seconds in Chrome input=time - Stack Overflow
Finally, I am including a screenshot of how Chrome 23.0.1271.64 m renders the different time formats (on my machine); <input type="time" value="23:20:50.52" ...
Read more >
<input type="time"> - HTML: HyperText Markup Language | MDN
<input> elements of type time create input fields designed to let the user easily enter a time (hours and minutes, and optionally seconds)....
Read more >
Input Types for HTML Forms - W3docs
If the user's browser doesn't support range, it will fall back and show it as text input. To show the level, use the...
Read more >
Date and Time Input / Output - Snowflake Documentation
The sign prevents ambiguity when the fractional seconds or the time zone offset does not contain the maximum number of allowable digits. For...
Read more >
input (type=time) element - HTML Quick
If you don't know what an element is or how you must use it, ... pick an hour between 12:00 and 16:00 and...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found