Skip to content

fix(ui): Fix <DatePickerField> closing on click #13467

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

Merged
merged 1 commit into from
May 31, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,26 @@ import space from 'app/styles/space';
import InputField from './inputField';

export default class DatePickerField extends React.Component {
onChange = (onChange, onBlur, date) => {
handleChangeDate = (onChange, onBlur, date, close) => {
onChange(date, {});
onBlur(date, {});

// close dropdown menu
close();
};

render() {
return (
<InputField
{...this.props}
field={({onChange, onBlur, value, disabled, name, id, ...props}) => {
field={({onChange, onBlur, value, disabled, name, id}) => {
const dateObj = new Date(value);
const inputValue = !isNaN(dateObj.getTime()) ? dateObj : new Date();
const dateString = moment(inputValue).format('LL');

return (
<DropdownMenu>
{({isOpen, getRootProps, getActorProps, getMenuProps}) => (
<DropdownMenu keepMenuOpen>
{({isOpen, getRootProps, getActorProps, getMenuProps, actions}) => (
<DatePickerWrapper {...getRootProps({isStyled: true})}>
<InputWrapper
name={id}
Expand All @@ -49,7 +52,9 @@ export default class DatePickerField extends React.Component {
<Calendar
disabled={disabled}
date={inputValue}
onChange={date => this.onChange(onChange, onBlur, date)}
onChange={date =>
this.handleChangeDate(onChange, onBlur, date, actions.close)
}
/>
</CalendarMenu>
)}
Expand Down