mirror of
https://github.com/grafana/grafana.git
synced 2026-09-05 04:40:13 -05: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:
@@ -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 { 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>
|
||||
|
||||
Reference in New Issue
Block a user