From fcf652b8d994b47750b507e61ba7c0724bad7db6 Mon Sep 17 00:00:00 2001 From: Nathan Reese Date: Fri, 25 Jan 2019 10:57:21 -0700 Subject: [PATCH 1/3] EuiSuperDatePicker - always call onTimeChange when showUpdateButton is false --- .../super_date_picker/super_date_picker.js | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/components/date_picker/super_date_picker/super_date_picker.js b/src/components/date_picker/super_date_picker/super_date_picker.js index 214de7be14f..87b076189ba 100644 --- a/src/components/date_picker/super_date_picker/super_date_picker.js +++ b/src/components/date_picker/super_date_picker/super_date_picker.js @@ -31,7 +31,7 @@ export class EuiSuperDatePicker extends Component { */ end: PropTypes.string, /** - * Callback for when the time changes. Called with { start, end } + * Callback for when the time changes. Called with { start, end, isQuickSelection } */ onTimeChange: PropTypes.func.isRequired, isPaused: PropTypes.bool, @@ -146,11 +146,9 @@ export class EuiSuperDatePicker extends Component { hasChanged: true, }); - if (!isInvalid) { - if (!this.props.showUpdateButton) { - this.props.onTimeChange({ start, end }); - return; - } + if (!this.props.showUpdateButton) { + this.props.onTimeChange({ start, end, isQuickSelection: false }); + return; } } @@ -163,14 +161,17 @@ export class EuiSuperDatePicker extends Component { } applyTime = () => { - this.props.onTimeChange({ start: this.state.start, end: this.state.end }); + this.props.onTimeChange({ + start: this.state.start, + end: this.state.end, isQuickSelection: false + }); } applyQuickTime = ({ start, end }) => { this.setState({ showPrettyDuration: showPrettyDuration(start, end, this.props.commonlyUsedRanges), }); - this.props.onTimeChange({ start, end }); + this.props.onTimeChange({ start, end, isQuickSelection: true }); } hidePrettyDuration = () => { From 6194149afa9b5df8b6e46c08dda9c650d8d09845 Mon Sep 17 00:00:00 2001 From: Nathan Reese Date: Fri, 25 Jan 2019 11:02:18 -0700 Subject: [PATCH 2/3] changelog --- CHANGELOG.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2a57941f00a..698dcec7d88 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,8 @@ ## [`master`](https://github.com/elastic/eui/tree/master) -No public interface changes since `6.7.1`. +**Bug fixes** + +- `EuiSuperDatePicker` always trigger `onTimeChange` when time changes and prop `showUpdateButton` is false ([#1477](https://github.com/elastic/eui/pull/1477)) ## [`6.7.1`](https://github.com/elastic/eui/tree/v6.7.1) From b1db9cc44bf0c7b4397f1661bf2233fd0a916ae0 Mon Sep 17 00:00:00 2001 From: Nathan Reese Date: Fri, 25 Jan 2019 12:50:48 -0700 Subject: [PATCH 3/3] pass isInvalid to onTimeChange --- .../super_date_picker/super_date_picker.js | 21 ++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/src/components/date_picker/super_date_picker/super_date_picker.js b/src/components/date_picker/super_date_picker/super_date_picker.js index 87b076189ba..aee6f091da4 100644 --- a/src/components/date_picker/super_date_picker/super_date_picker.js +++ b/src/components/date_picker/super_date_picker/super_date_picker.js @@ -31,7 +31,7 @@ export class EuiSuperDatePicker extends Component { */ end: PropTypes.string, /** - * Callback for when the time changes. Called with { start, end, isQuickSelection } + * Callback for when the time changes. Called with { start, end, isQuickSelection, isInvalid } */ onTimeChange: PropTypes.func.isRequired, isPaused: PropTypes.bool, @@ -147,8 +147,12 @@ export class EuiSuperDatePicker extends Component { }); if (!this.props.showUpdateButton) { - this.props.onTimeChange({ start, end, isQuickSelection: false }); - return; + this.props.onTimeChange({ + start, + end, + isQuickSelection: false, + isInvalid, + }); } } @@ -163,7 +167,9 @@ export class EuiSuperDatePicker extends Component { applyTime = () => { this.props.onTimeChange({ start: this.state.start, - end: this.state.end, isQuickSelection: false + end: this.state.end, + isQuickSelection: false, + isInvalid: false, }); } @@ -171,7 +177,12 @@ export class EuiSuperDatePicker extends Component { this.setState({ showPrettyDuration: showPrettyDuration(start, end, this.props.commonlyUsedRanges), }); - this.props.onTimeChange({ start, end, isQuickSelection: true }); + this.props.onTimeChange({ + start, + end, + isQuickSelection: true, + isInvalid: false + }); } hidePrettyDuration = () => {