mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-08-11 00:39:00 +08:00
refactor: onblur convert to tag (#4662)
* refactor: onblur convert to tag * refactor: on blur log body contains --------- Co-authored-by: Srikanth Chekuri <srikanth.chekuri92@gmail.com>
This commit is contained in:
parent
dd2afe19f6
commit
d9b379ae51
@ -59,6 +59,7 @@ function QueryBuilderSearch({
|
|||||||
updateTag,
|
updateTag,
|
||||||
handleClearTag,
|
handleClearTag,
|
||||||
handleKeyDown,
|
handleKeyDown,
|
||||||
|
handleOnBlur,
|
||||||
handleSearch,
|
handleSearch,
|
||||||
handleSelect,
|
handleSelect,
|
||||||
tags,
|
tags,
|
||||||
@ -260,6 +261,7 @@ function QueryBuilderSearch({
|
|||||||
notFoundContent={isFetching ? <Spin size="small" /> : null}
|
notFoundContent={isFetching ? <Spin size="small" /> : null}
|
||||||
suffixIcon={suffixIcon}
|
suffixIcon={suffixIcon}
|
||||||
showAction={['focus']}
|
showAction={['focus']}
|
||||||
|
onBlur={handleOnBlur}
|
||||||
>
|
>
|
||||||
{options.map((option) => (
|
{options.map((option) => (
|
||||||
<Select.Option key={option.label} value={option.value}>
|
<Select.Option key={option.label} value={option.value}>
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import { OPERATORS } from 'constants/queryBuilder';
|
||||||
import {
|
import {
|
||||||
getRemovePrefixFromKey,
|
getRemovePrefixFromKey,
|
||||||
getTagToken,
|
getTagToken,
|
||||||
@ -10,7 +11,7 @@ import { KeyboardEvent, useCallback, useState } from 'react';
|
|||||||
import { IBuilderQuery } from 'types/api/queryBuilder/queryBuilderData';
|
import { IBuilderQuery } from 'types/api/queryBuilder/queryBuilderData';
|
||||||
|
|
||||||
import { useFetchKeysAndValues } from './useFetchKeysAndValues';
|
import { useFetchKeysAndValues } from './useFetchKeysAndValues';
|
||||||
import { useOptions } from './useOptions';
|
import { useOptions, WHERE_CLAUSE_CUSTOM_SUFFIX } from './useOptions';
|
||||||
import { useSetCurrentKeyAndOperator } from './useSetCurrentKeyAndOperator';
|
import { useSetCurrentKeyAndOperator } from './useSetCurrentKeyAndOperator';
|
||||||
import { useTag } from './useTag';
|
import { useTag } from './useTag';
|
||||||
import { useTagValidation } from './useTagValidation';
|
import { useTagValidation } from './useTagValidation';
|
||||||
@ -98,6 +99,23 @@ export const useAutoComplete = (
|
|||||||
[handleAddTag, handleClearTag, isMulti, isValidTag, searchValue, tags],
|
[handleAddTag, handleClearTag, isMulti, isValidTag, searchValue, tags],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const handleOnBlur = (event: React.FocusEvent<HTMLInputElement>): void => {
|
||||||
|
event.preventDefault();
|
||||||
|
if (searchValue) {
|
||||||
|
if (
|
||||||
|
key &&
|
||||||
|
!operator &&
|
||||||
|
whereClauseConfig?.customKey === 'body' &&
|
||||||
|
whereClauseConfig.customOp === OPERATORS.CONTAINS
|
||||||
|
) {
|
||||||
|
const value = `${searchValue}${WHERE_CLAUSE_CUSTOM_SUFFIX}`;
|
||||||
|
handleAddTag(value);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
handleAddTag(searchValue);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const options = useOptions(
|
const options = useOptions(
|
||||||
key,
|
key,
|
||||||
keys,
|
keys,
|
||||||
@ -117,6 +135,7 @@ export const useAutoComplete = (
|
|||||||
handleClearTag,
|
handleClearTag,
|
||||||
handleSelect,
|
handleSelect,
|
||||||
handleKeyDown,
|
handleKeyDown,
|
||||||
|
handleOnBlur,
|
||||||
options,
|
options,
|
||||||
tags,
|
tags,
|
||||||
searchValue,
|
searchValue,
|
||||||
@ -133,6 +152,7 @@ interface IAutoComplete {
|
|||||||
handleClearTag: (value: string) => void;
|
handleClearTag: (value: string) => void;
|
||||||
handleSelect: (value: string) => void;
|
handleSelect: (value: string) => void;
|
||||||
handleKeyDown: (event: React.KeyboardEvent) => void;
|
handleKeyDown: (event: React.KeyboardEvent) => void;
|
||||||
|
handleOnBlur: (event: React.FocusEvent<HTMLInputElement>) => void;
|
||||||
options: Option[];
|
options: Option[];
|
||||||
tags: string[];
|
tags: string[];
|
||||||
searchValue: string;
|
searchValue: string;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user