fix: chartpage querying too on every keystroke after initial query (#870)

This commit is contained in:
Aaron Knudtson 2025-05-28 17:58:31 -04:00 committed by GitHub
parent e27c24a13f
commit d176b54b4e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 15 additions and 3 deletions

View file

@ -0,0 +1,5 @@
---
"@hyperdx/app": patch
---
fix: chartpage querying too on every keystroke after initial query

View file

@ -406,8 +406,8 @@ export default function EditTimeChartForm({
setChartConfig(form);
if (tableSource != null) {
const isSelectEmpty = !form.select || form.select.length === 0; // select is string or array
setQueriedConfig({
...structuredClone(form),
const newConfig = {
...form,
from: tableSource.from,
timestampValueExpression: tableSource.timestampValueExpression,
dateRange,
@ -417,7 +417,14 @@ export default function EditTimeChartForm({
select: isSelectEmpty
? tableSource.defaultTableSelectExpression || ''
: form.select,
});
};
setQueriedConfig(
// WARNING: DON'T JUST ASSIGN OBJECTS OR DO SPREAD OPERATOR STUFF WHEN
// YOUR STATE IS AN OBJECT. YOU'RE COPYING BY REFERENCE WHICH MIGHT
// ACCIDENTALLY CAUSE A useQuery SOMEWHERE TO FIRE A REQUEST EVERYTIME
// AN INPUT CHANGES. USE structuredClone TO PERFORM A DEEP COPY INSTEAD
structuredClone(newConfig),
);
}
})();
}, [handleSubmit, setChartConfig, setQueriedConfig, tableSource, dateRange]);