Skip to content
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

fix(DatePicker): allow locale object to be passed in to flatpickr #7834

Merged
merged 3 commits into from
Feb 19, 2021

Conversation

tw15egan
Copy link
Member

Closes #7823

This PR allows additional Flatpickr props, such as firstDayOfWeek, to be passed down via the locale prop

Changelog

New

  • Instead of directly passing down locale to flatpickr and only accepting a locale string (thus stripping additional props), it now checks if locale is a string or object.
  • If it is a string, it works as before.
  • If it is an object, it first locates the locale string (defaults to en if not provided), then spread additional passed down props to the new localeData object. localeData is then passed down to `Flatpickr, either as an object containing the locale data and additional props, or just the locale data

Testing / Reviewing

Locally, edit the DatePicker-story.js and try the following 3 variants ad ensure it renders as expected

<DatePicker datePickerType="single">
<DatePicker datePickerType="single" locale={{locale: 'no',  firstDayOfWeek: 1 }}>
<DatePicker datePickerType="single" locale={{ firstDayOfWeek: 1 }}>

@tw15egan tw15egan requested a review from a team as a code owner February 17, 2021 22:45
@netlify
Copy link

netlify bot commented Feb 17, 2021

Deploy preview for carbon-elements ready!

Built with commit 480075b

https://deploy-preview-7834--carbon-elements.netlify.app

@netlify
Copy link

netlify bot commented Feb 17, 2021

Deploy preview for carbon-components-react ready!

Built with commit 480075b

https://deploy-preview-7834--carbon-components-react.netlify.app

@netlify
Copy link

netlify bot commented Feb 17, 2021

Deploy preview for carbon-elements ready!

Built with commit 1fdff32

https://deploy-preview-7834--carbon-elements.netlify.app

@tw15egan tw15egan requested a review from a team as a code owner February 17, 2021 23:06
@netlify
Copy link

netlify bot commented Feb 17, 2021

Deploy preview for carbon-components-react ready!

Built with commit 23edd71

https://deploy-preview-7834--carbon-components-react.netlify.app

@netlify
Copy link

netlify bot commented Feb 17, 2021

Deploy preview for carbon-components-react ready!

Built without sensitive environment variables with commit 1fdff32

https://deploy-preview-7834--carbon-components-react.netlify.app

@kodiakhq kodiakhq bot merged commit bdf9f5c into carbon-design-system:master Feb 19, 2021
@tw15egan tw15egan deleted the date-picker-update branch March 3, 2022 16:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Datepicker does not pass all props to flatpickr
3 participants