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.

Controls with control: text unexpectedly translate ISO 8601 formatted datetime

See original GitHub issue

Imagine any text input element as a story Template described by:

<Meta
  title="TextInput"
  argTypes={{
    value: {
      control: 'text',
    },
  }}
  args={{
    value: '',
  }}
/>
<Story
    name="Datetime in ISO format"
    args={{
      value: '2021-01-21T20:02:26Z',
    }}
>
  {Template.bind({})}
</Story>

Instead of displaying a provided value of 2021-01-21T20:02:26Z, the controls suddenly jump to conclusions and decide to do some black-box magic, translating this to Thu Jan 21 2021 21:02:26 GMT+0100 (Central European Standard Time).

image

I’m sure this should be an opt-in feature rather than taking away our ability to visually test & document any time-related inputs. I couldn’t find any workaround, considering that the string input doesn’t provide any other alternative to the ‘text’.

  • (Btw. my specific use-case also requires updating the control by modifying displayed value when a custom input emits any change, but it seems that updating control from inside the story isn’t supported by this framework either.)

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:3
  • Comments:15 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
scscgitcommented, Jan 23, 2021

Hi @yannbf, thanks, but my specific use-case is actually about working with the ISO value as a text, so the date control would just make it even more ambiguous about which value is really being passed (making it more difficult to manually test correct inputs).

2reactions
ndelangencommented, Dec 14, 2022

@BikashSah999 a fix in our codebase would break for users who DO want those dates to be converted to date Classes.

Yeah, this seems like a good candidate for why you’d want to change the channelOptions in your main.js. I get it’s not optimal for you, but I don’t really see another way. There are no true date values in JSON, it must be a string. So SOME sort of string is going to be converted back into a Date class instance… I’m open to novel ideas, of course!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Datetime string must match ISO 8601 error
Hi, I am having trouble getting my flow to run correctly. A user creates a new item via a PowerApps App which collects...
Read more >
DateTimeFormatter - Android Developers
The ISO-like date-time formatter that formats or parses a date-time with ... Parses the text using this formatter, providing control over the text...
Read more >
JavaScript JSON Date Parsing and real Dates - Rick Strahl
Dates are encoded as ISO 8601 strings and then treated just like a regular string when the JSON is serialized and deserialized. You...
Read more >
What is ISO 8601 DateTime format? - xFanatical
This whole sequence containing the particulars is interpreted as a customized date and time format string. Here, we will discuss the ISO 8601...
Read more >
IO tools (text, CSV, HDF5, …) — pandas 1.5.2 documentation
text. CSV. read_csv. to_csv. text. Fixed-Width Text File. read_fwf. text ... read_csv has a fast_path for parsing datetime strings in iso8601 format, ...
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