Skip to content

Commit 61cb942

Browse files
only run sample query when visible (#1499)
Improves the Chart Explorer page to only run the sample query when the accordion is open and visible. Also changed default to closed since it's below the fold. @pulpdrew assigned to you as you originally observed this issue Demo: https://github.com/user-attachments/assets/6108323a-767f-4e9f-88cf-4b9e2de9def1 Fixes HDX-2895
1 parent b99052a commit 61cb942

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

.changeset/silver-mugs-obey.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@hyperdx/app": patch
3+
---
4+
5+
Performance Improvement to only run sample query when the table is visible

packages/app/src/components/DBEditTimeChartForm.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -475,6 +475,8 @@ export default function EditTimeChartForm({
475475
name: 'series',
476476
});
477477

478+
const [isSampleEventsOpen, setIsSampleEventsOpen] = useState(false);
479+
478480
const select = watch('select');
479481
const sourceId = watch('source');
480482
const whereLanguage = watch('whereLanguage');
@@ -1234,7 +1236,10 @@ export default function EditTimeChartForm({
12341236
<>
12351237
<Divider mt="md" />
12361238
{showSampleEvents && (
1237-
<Accordion defaultValue="sample">
1239+
<Accordion
1240+
value={isSampleEventsOpen ? 'sample' : null}
1241+
onChange={value => setIsSampleEventsOpen(value === 'sample')}
1242+
>
12381243
<Accordion.Item value="sample">
12391244
<Accordion.Control icon={<IconList size={16} />}>
12401245
<Text size="sm" style={{ alignSelf: 'center' }}>
@@ -1250,7 +1255,7 @@ export default function EditTimeChartForm({
12501255
<DBSqlRowTableWithSideBar
12511256
sourceId={sourceId}
12521257
config={sampleEventsConfig}
1253-
enabled
1258+
enabled={isSampleEventsOpen}
12541259
isLive={false}
12551260
queryKeyPrefix={'search'}
12561261
/>

0 commit comments

Comments
 (0)