mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Explore: adds an ability to exit log row context with ESC key (#24205)
* Chore: adds event listeners allowing to exit log row context with ESC key
* Chore: updates LogRows styles to prevent it from rendering context provider inappropriately
* Revert "Chore: updates LogRows styles to prevent it from rendering context provider inappropriately"
This reverts commit 59b06424c4
.
This commit is contained in:
parent
5a6026a8c0
commit
de46dc7af0
@ -1,4 +1,4 @@
|
|||||||
import React, { useContext, useRef, useState, useLayoutEffect } from 'react';
|
import React, { useContext, useRef, useState, useLayoutEffect, useEffect } from 'react';
|
||||||
import { LogRowModel } from '@grafana/data';
|
import { LogRowModel } from '@grafana/data';
|
||||||
import { css, cx } from 'emotion';
|
import { css, cx } from 'emotion';
|
||||||
|
|
||||||
@ -202,6 +202,19 @@ export const LogRowContext: React.FunctionComponent<LogRowContextProps> = ({
|
|||||||
onLoadMoreContext,
|
onLoadMoreContext,
|
||||||
hasMoreContextRows,
|
hasMoreContextRows,
|
||||||
}) => {
|
}) => {
|
||||||
|
const handleEscKeyDown = (e: KeyboardEvent): void => {
|
||||||
|
if (e.keyCode === 27) {
|
||||||
|
onOutsideClick();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
document.addEventListener('keydown', handleEscKeyDown, false);
|
||||||
|
return () => {
|
||||||
|
document.removeEventListener('keydown', handleEscKeyDown, false);
|
||||||
|
};
|
||||||
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ClickOutsideWrapper onClick={onOutsideClick}>
|
<ClickOutsideWrapper onClick={onOutsideClick}>
|
||||||
<div>
|
<div>
|
||||||
|
Loading…
Reference in New Issue
Block a user