mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-07-25 14:34:24 +08:00
feat: added focus for qb search for last search bar (#4534)
This commit is contained in:
parent
d6b7587bbe
commit
037f5ae4c8
@ -5,5 +5,5 @@ export const LogsExplorerShortcuts = {
|
|||||||
|
|
||||||
export const LogsExplorerShortcutsDescription = {
|
export const LogsExplorerShortcutsDescription = {
|
||||||
StageAndRunQuery: 'Stage and Run the current query',
|
StageAndRunQuery: 'Stage and Run the current query',
|
||||||
FocusTheSearchBar: 'Shift the focus to the filter bar',
|
FocusTheSearchBar: 'Shift the focus to the last query filter bar',
|
||||||
};
|
};
|
||||||
|
@ -2,13 +2,16 @@ import './QueryBuilderSearch.styles.scss';
|
|||||||
|
|
||||||
import { Select, Spin, Tag, Tooltip } from 'antd';
|
import { Select, Spin, Tag, Tooltip } from 'antd';
|
||||||
import { OPERATORS } from 'constants/queryBuilder';
|
import { OPERATORS } from 'constants/queryBuilder';
|
||||||
|
import { LogsExplorerShortcuts } from 'constants/shortcuts/logsExplorerShortcuts';
|
||||||
import { getDataTypes } from 'container/LogDetailedView/utils';
|
import { getDataTypes } from 'container/LogDetailedView/utils';
|
||||||
|
import { useKeyboardHotkeys } from 'hooks/hotkeys/useKeyboardHotkeys';
|
||||||
import {
|
import {
|
||||||
useAutoComplete,
|
useAutoComplete,
|
||||||
WhereClauseConfig,
|
WhereClauseConfig,
|
||||||
} from 'hooks/queryBuilder/useAutoComplete';
|
} from 'hooks/queryBuilder/useAutoComplete';
|
||||||
import { useFetchKeysAndValues } from 'hooks/queryBuilder/useFetchKeysAndValues';
|
import { useFetchKeysAndValues } from 'hooks/queryBuilder/useFetchKeysAndValues';
|
||||||
import { useQueryBuilder } from 'hooks/queryBuilder/useQueryBuilder';
|
import { useQueryBuilder } from 'hooks/queryBuilder/useQueryBuilder';
|
||||||
|
import { isEqual } from 'lodash-es';
|
||||||
import type { BaseSelectRef } from 'rc-select';
|
import type { BaseSelectRef } from 'rc-select';
|
||||||
import {
|
import {
|
||||||
KeyboardEvent,
|
KeyboardEvent,
|
||||||
@ -75,7 +78,9 @@ function QueryBuilderSearch({
|
|||||||
searchKey,
|
searchKey,
|
||||||
);
|
);
|
||||||
|
|
||||||
const { handleRunQuery } = useQueryBuilder();
|
const { registerShortcut, deregisterShortcut } = useKeyboardHotkeys();
|
||||||
|
|
||||||
|
const { handleRunQuery, currentQuery } = useQueryBuilder();
|
||||||
|
|
||||||
const onTagRender = ({
|
const onTagRender = ({
|
||||||
value,
|
value,
|
||||||
@ -197,9 +202,32 @@ function QueryBuilderSearch({
|
|||||||
});
|
});
|
||||||
|
|
||||||
onChange(initialTagFilters);
|
onChange(initialTagFilters);
|
||||||
/* eslint-disable react-hooks/exhaustive-deps */
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
}, [sourceKeys]);
|
}, [sourceKeys]);
|
||||||
|
|
||||||
|
const isLastQuery = useMemo(
|
||||||
|
() =>
|
||||||
|
isEqual(
|
||||||
|
currentQuery.builder.queryData[currentQuery.builder.queryData.length - 1],
|
||||||
|
query,
|
||||||
|
),
|
||||||
|
[currentQuery, query],
|
||||||
|
);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (isLastQuery) {
|
||||||
|
registerShortcut(LogsExplorerShortcuts.FocusTheSearchBar, () => {
|
||||||
|
// set timeout is needed here else the select treats the hotkey as input value
|
||||||
|
setTimeout(() => {
|
||||||
|
selectRef.current?.focus();
|
||||||
|
}, 0);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return (): void =>
|
||||||
|
deregisterShortcut(LogsExplorerShortcuts.FocusTheSearchBar);
|
||||||
|
}, [deregisterShortcut, isLastQuery, registerShortcut]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
style={{
|
style={{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user