Skip to content

Commit

Permalink
EuiSuperDatePicker - always call onTimeChange when showUpdateButton i…
Browse files Browse the repository at this point in the history
…s false (#1477)

* EuiSuperDatePicker - always call onTimeChange when showUpdateButton is false

* changelog

* pass isInvalid to onTimeChange
  • Loading branch information
nreese authored Jan 25, 2019
1 parent 47ebb31 commit 17fdc20
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 9 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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)

Expand Down
28 changes: 20 additions & 8 deletions src/components/date_picker/super_date_picker/super_date_picker.js
Original file line number Diff line number Diff line change
Expand Up @@ -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, isInvalid }
*/
onTimeChange: PropTypes.func.isRequired,
isPaused: PropTypes.bool,
Expand Down Expand Up @@ -146,11 +146,13 @@ 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,
isInvalid,
});
}
}

Expand All @@ -163,14 +165,24 @@ 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,
isInvalid: 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,
isInvalid: false
});
}

hidePrettyDuration = () => {
Expand Down

0 comments on commit 17fdc20

Please sign in to comment.