Skip to content

Commit

Permalink
fix: range plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
riddhybansal committed Apr 19, 2024
1 parent 5c1e7d6 commit 1306f1d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export const SingleWithCalendar = () => (

export const RangeWithCalendar = () => {
return (
<DatePicker allowInput={false} datePickerType="range">
<DatePicker datePickerType="range">
<DatePickerInput
id="date-picker-input-id-start"
placeholder="mm/dd/yyyy"
Expand Down Expand Up @@ -108,7 +108,7 @@ export const SingleWithCalendarWithLayer = () => (
export const RangeWithCalendarWithLayer = () => (
<WithLayer>
{(layer) => (
<DatePicker allowInput={false} datePickerType="range">
<DatePicker datePickerType="range">
<DatePickerInput
id={`date-picker-input-id-start-${layer}`}
placeholder="mm/dd/yyyy"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@ export default (config) => {
// If `triggerChange` is `true`, `onValueUpdate` Flatpickr event is fired
// where Flatpickr's range plugin takes care of fixing the first `<input>`
if (!triggerChange) {
const { _input: inputFrom } = fp;
const { input: inputTo } = config;
[inputFrom, inputTo].forEach((input, i) => {
const { _input: inputDates } = fp;
const inputDatesArray = inputDates.value.split(' ');
fp.close();
[inputDatesArray[0], inputDatesArray[2]].forEach((input, i) => {
if (input) {
input.value = !dates[i]
input = !dates[i]
? ''
: fp.formatDate(new Date(dates[i]), fp.config.dateFormat);
}
Expand Down

0 comments on commit 1306f1d

Please sign in to comment.