Skip to content

Commit 5a91dea

Browse files
committed
Only show the loading state when there's not data already
1 parent 0524baa commit 5a91dea

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

apps/webapp/app/components/metrics/QueryWidget.tsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,12 @@ function QueryWidgetBody({
319319
}: QueryWidgetBodyProps) {
320320
const type = config.type;
321321

322+
// Only show the loading state if we have no data yet (initial load).
323+
// During a reload with existing data, keep showing the current data
324+
// while the loading bar in the header indicates a refresh is in progress.
325+
const hasData = data.rows.length > 0;
326+
const showLoading = isLoading && !hasData;
327+
322328
switch (type) {
323329
case "table": {
324330
return (
@@ -363,7 +369,7 @@ function QueryWidgetBody({
363369
columns={data.columns}
364370
config={config}
365371
onViewAllLegendItems={() => setIsFullscreen(true)}
366-
isLoading={isLoading}
372+
isLoading={showLoading}
367373
/>
368374
</div>
369375
</DialogContent>
@@ -378,7 +384,7 @@ function QueryWidgetBody({
378384
rows={data.rows}
379385
columns={data.columns}
380386
config={config}
381-
isLoading={isLoading}
387+
isLoading={showLoading}
382388
/>
383389
<Dialog open={isFullscreen} onOpenChange={setIsFullscreen}>
384390
<DialogContent fullscreen>
@@ -388,7 +394,7 @@ function QueryWidgetBody({
388394
rows={data.rows}
389395
columns={data.columns}
390396
config={config}
391-
isLoading={isLoading}
397+
isLoading={showLoading}
392398
/>
393399
</div>
394400
</DialogContent>

0 commit comments

Comments
 (0)