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

[EuiSuperDatePicker] date popover onChange should only accept strings #3460

Merged
merged 6 commits into from
May 14, 2020
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
**Bug Fixes**

- Fixed `EuiSuperDatePicker` quick selection menu overriding specified time range with default values ([#3446](https://github.com/elastic/eui/pull/3446))
- Fixed `EuiDatePopoverContent` `onChange` event to only accept `string` date input ([#3460](https://github.com/elastic/eui/pull/3460))

**Breaking changes**

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import moment, { Moment, LocaleSpecifier } from 'moment'; // eslint-disable-line

import dateMath from '@elastic/datemath';

import { EuiDatePicker } from '../../date_picker';
import { EuiDatePicker, EuiDatePickerProps } from '../../date_picker';
import { EuiFormRow, EuiFieldText, EuiFormLabel } from '../../../form';
import { toSentenceCase } from '../../../../services/string/to_case';
import { EuiDatePopoverContentProps } from './date_popover_content';
Expand Down Expand Up @@ -73,12 +73,12 @@ export class EuiAbsoluteTab extends Component<
};
}

handleChange: EuiDatePopoverContentProps['onChange'] = (date, event) => {
handleChange: EuiDatePickerProps['onChange'] = (date, event) => {
const { onChange } = this.props;
if (date === null) {
return;
}
onChange(typeof date === 'string' ? date : date.toISOString(), event);
onChange(date.toISOString(), event);

const valueAsMoment = moment(date);
this.setState({
Expand All @@ -97,7 +97,7 @@ export class EuiAbsoluteTab extends Component<
);
const dateIsValid = valueAsMoment.isValid();
if (dateIsValid) {
onChange(valueAsMoment, event);
onChange(valueAsMoment.toISOString(), event);
}
this.setState({
textInputValue: event.target.value as string,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,11 @@ import {
toAbsoluteString,
toRelativeString,
} from '../date_modes';
import { Moment, LocaleSpecifier } from 'moment'; // eslint-disable-line import/named
import { LocaleSpecifier } from 'moment'; // eslint-disable-line import/named

export interface EuiDatePopoverContentProps {
value: string;
onChange(
date: Moment | string | null,
event?: React.SyntheticEvent<any>
): void;
onChange(date: string | null, event?: React.SyntheticEvent<any>): void;
roundUp?: boolean;
dateFormat: string;
timeFormat: string;
Expand Down