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.

DatePicker component seems to behave incorrectly when using localization

See original GitHub issue

What package has an issue

@mantine/dates

Describe the bug

I’m having a little bit of trouble with the DatePicker component when using localization: if you select a date for a split second the first character of the month is uppercase and then it switches back to lowercase (it is very fast). Furthermore it doesn’t seem to use any format of the locale I selected (https://github.com/iamkun/dayjs/blob/dev/src/locale/it.js) but it is translating month names correctly.

In which browser did the problem occur

Firefox 102.0.1

If possible, please include a link to a codesandbox with the reproduced problem

https://codesandbox.io/s/goofy-browser-ducwiy?file=/src/App.tsx

Do you know how to fix the issue

No response

Are you willing to participate in fixing this issue and create a pull request with the fix

No response

Possible fix

I worked around both problems this way https://codesandbox.io/s/ancient-glade-0ezu2h?file=/src/App.tsx I dynamically load dayjs locales so I can read the formats and I apply them using dateFormat on the MantineProvider. I’m not even sure if dateFormat is a documented property as I got it from source code and couldn’t find it on the documentation.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
ercgratcommented, Jul 24, 2022

Hi @esistgut, I opened a PR that fixes the capitalization glitch you noticed.

Otherwise, there is also an inputFormat prop on the DatePicker component that you can use. It also happens not to be documented. The locale-specific formats will only be recognized if you extend dayjs with the localizedFormat plugin. I made a CodePen that shows this: https://codesandbox.io/s/eager-shirley-7srfg2?file=/src/App.tsx

Here’s the dayjs doc page on the topic: https://day.js.org/docs/en/plugin/localized-format

@rtivital would you mind if I open a PR adding documentation for the inputFormat prop with this context?

0reactions
rtivitalcommented, Jul 30, 2022

Fixed in 5.0.2

Read more comments on GitHub >

github_iconTop Results From Across the Web

Date Selected is One Day Off · Issue #1018 - GitHub
Hi, I'm having an interesting issue with my usage of the datepicker component. My code is pretty basic, it looks like this: <ReactDatePicker ......
Read more >
SwiftUI Date Picker is Problematic | Apple Developer Forums
The date format is getting changed with specific dates and not everytime i select a new one. BUT, I found a workaround. You...
Read more >
Bootstrap Datepicker appearing at incorrect location in a modal
Datetimepicker will show in a wrong place if the container of the input is not positioned relative. The solution is ...
Read more >
493141 - Date Picker Incorrectly Interprets Input Date Max and ...
Issue 493141: Date Picker Incorrectly Interprets Input Date Max and Min ... I chatted with tkent@ offline and it seems that max value...
Read more >
Uncaught TypeError with datepicker localization - EJ 2 Forums
Hi, I'm facing an issue with datepicker localization. I'm attaching the demo project I tried for you to reproduce the issue.
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