mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
TimePicker: Close timepicker with esc (#39962)
This commit is contained in:
parent
2a4c1b1aa6
commit
3cd7b11eb4
@ -66,6 +66,20 @@ export class UnthemedTimeRangePicker extends PureComponent<TimeRangePickerProps,
|
||||
this.setState({ isOpen: !isOpen });
|
||||
};
|
||||
|
||||
componentDidMount() {
|
||||
window.addEventListener('keyup', this.onKeyUp);
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
window.removeEventListener('keyup', this.onKeyUp);
|
||||
}
|
||||
|
||||
onKeyUp = (event: KeyboardEvent) => {
|
||||
if (event.code === 'Escape') {
|
||||
this.onClose();
|
||||
}
|
||||
};
|
||||
|
||||
onClose = () => {
|
||||
this.setState({ isOpen: false });
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user