Skip to content
This repository has been archived by the owner on Feb 1, 2024. It is now read-only.

Commit

Permalink
Merge pull request #2376 from teamleadercrm/date-picker-input-fixes
Browse files Browse the repository at this point in the history
DatePickerInput fixes
  • Loading branch information
BeirlaenAaron authored Sep 26, 2022
2 parents 234a5ec + 854d57e commit 182eafe
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

### Fixed

- `DatePickerInput`: fix the DatePicker input value not changing if the selectedDate prop changes and extend `DayPickerProps` with React's DayPickerProps ([@BeirlaenAaron](https://github.com/BeirlaenAaron)) in [#2376](https://github.com/teamleadercrm/ui/pull/2376))

### Dependency updates

## [16.2.1] - 2022-09-23
Expand Down
9 changes: 7 additions & 2 deletions src/components/datepicker/DatePickerInput.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { ReactNode, useState } from 'react';
import React, { ReactNode, useEffect, useState } from 'react';
import Box, { pickBoxProps } from '../box';
import DatePicker from '.';
import Icon from '../icon';
Expand All @@ -13,6 +13,7 @@ import { GenericComponent } from '../../@types/types';
import { SIZES } from '../../constants';
import { InputProps } from '../input/Input';
import { PopoverProps } from '../popover/Popover';
import { DayPickerProps as ReactDayPickerProps } from 'react-day-picker';

interface DatePickerInputProps extends Omit<BoxProps, 'size' | 'onChange'> {
/** A class name for the wrapper to give custom styles. */
Expand Down Expand Up @@ -47,7 +48,7 @@ interface DatePickerInputProps extends Omit<BoxProps, 'size' | 'onChange'> {
openPickerOnFocus?: boolean;
}

interface DayPickerProps {
interface DayPickerProps extends Omit<ReactDayPickerProps, 'modifiers'> {
numberOfMonths?: number;
showOutsideDays?: boolean;
showWeekNumbers?: boolean;
Expand Down Expand Up @@ -130,6 +131,10 @@ const DatePickerInput: GenericComponent<DatePickerInputProps> = ({
);
};

useEffect(() => {
setSelectedDate(others.selectedDate);
}, [others.selectedDate]);

const boxProps = pickBoxProps(others);
const datePickerClassNames = cx(theme['date-picker-input'], theme[`is-${datePickerSize || size}`]);

Expand Down

0 comments on commit 182eafe

Please sign in to comment.