Commit de46dc7a by Lukas Siatka Committed by GitHub

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 59b06424c49bf4c33a1b6419551f76ff5de6e122.
parent 5a6026a8
import React, { useContext, useRef, useState, useLayoutEffect } from 'react';
import React, { useContext, useRef, useState, useLayoutEffect, useEffect } from 'react';
import { LogRowModel } from '@grafana/data';
import { css, cx } from 'emotion';
......@@ -202,6 +202,19 @@ export const LogRowContext: React.FunctionComponent<LogRowContextProps> = ({
onLoadMoreContext,
hasMoreContextRows,
}) => {
const handleEscKeyDown = (e: KeyboardEvent): void => {
if (e.keyCode === 27) {
onOutsideClick();
}
};
useEffect(() => {
document.addEventListener('keydown', handleEscKeyDown, false);
return () => {
document.removeEventListener('keydown', handleEscKeyDown, false);
};
}, []);
return (
<ClickOutsideWrapper onClick={onOutsideClick}>
<div>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment