SigNoz is an open-source, OpenTelemetry-native observability platform for your team and their AI agents. Get logs, metrics, and traces in one tool with features like APM, distributed tracing, log management, infra monitoring, etc. Combined with SigNoz MCP and a native AI teammate (in SigNoz Cloud) it helps you build more resilient apps.
TypeScript apmapplication-monitoringdistributed-tracinggogood-first-issuejaegerloglogsmetricsmonitoringnextjsobservabilityopen-sourceopentelemetryprometheusreactreactjsself-hostedtracingtypescript
fix: solved re-render issue when input fields were edited (#2149)
Amol Umbarkfaaf0a6e73de
diff --git a/frontend/src/container/LogsSearchFilter/SearchFields/QueryBuilder/QueryBuilder.tsx b/frontend/src/container/LogsSearchFilter/SearchFields/QueryBuilder/QueryBuilder.tsxindex 5b06c3ca82..0859e12499 100644--- a/frontend/src/container/LogsSearchFilter/SearchFields/QueryBuilder/QueryBuilder.tsx+++ b/frontend/src/container/LogsSearchFilter/SearchFields/QueryBuilder/QueryBuilder.tsx@@ -175,6 +175,7 @@ export interface QueryBuilderProps {onDropDownToggleHandler: (value: boolean) => VoidFunction;fieldsQuery: QueryFields[][];setFieldsQuery: (q: QueryFields[][]) => void;+ syncKeyPrefix: () => void;}function QueryBuilder({@@ -182,6 +183,7 @@ function QueryBuilder({fieldsQuery,setFieldsQuery,onDropDownToggleHandler,+ syncKeyPrefix,}: QueryBuilderProps): JSX.Element {const handleUpdate = (query: Query, queryIndex: number): void => {const updated = [...fieldsQuery];@@ -195,6 +197,9 @@ function QueryBuilder({else updated.splice(queryIndex, 2);setFieldsQuery(updated);++ // initiate re-render query panel+ syncKeyPrefix();};const QueryUI = (diff --git a/frontend/src/container/LogsSearchFilter/SearchFields/index.tsx b/frontend/src/container/LogsSearchFilter/SearchFields/index.tsxindex 50e2947ed2..5fcd180515 100644--- a/frontend/src/container/LogsSearchFilter/SearchFields/index.tsx+++ b/frontend/src/container/LogsSearchFilter/SearchFields/index.tsx@@ -47,9 +47,12 @@ function SearchFields({}}, [parsedQuery]);- const updateFieldsQuery = (updated: QueryFields[][]): void => {- setFieldsQuery(updated);- keyPrefixRef.current = hashCode(JSON.stringify(updated));+ // syncKeyPrefix initiates re-render. useful in situations like+ // delete field (in search panel). this method allows condiitonally+ // setting keyPrefix as doing it on every update of query initiates+ // a re-render. this is a problem for text fields where input focus goes away.+ const syncKeyPrefix = (): void => {+ keyPrefixRef.current = hashCode(JSON.stringify(fieldsQuery));};const addSuggestedField = useCallback(@@ -102,7 +105,8 @@ function SearchFields({keyPrefix={keyPrefixRef.current}onDropDownToggleHandler={onDropDownToggleHandler}fieldsQuery={fieldsQuery}- setFieldsQuery={updateFieldsQuery}+ setFieldsQuery={setFieldsQuery}+ syncKeyPrefix={syncKeyPrefix}/><SearchFieldsActionBarapplyUpdate={applyUpdate}