Skip to content

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.

fix(dashboard-v2): bug bash fixes IV (#12056)

Abhi kumar1a1f7b2d783e
diff --git a/frontend/src/hooks/useIntersectionObserver.ts b/frontend/src/hooks/useIntersectionObserver.ts
index 50a23608e9..d449bd35d1 100644
--- a/frontend/src/hooks/useIntersectionObserver.ts
+++ b/frontend/src/hooks/useIntersectionObserver.ts
@@ -4,6 +4,8 @@ export function useIntersectionObserver<T extends HTMLElement>(
ref: RefObject<T>,
options?: IntersectionObserverInit,
isObserverOnce?: boolean,
+ /** Defer observation by this many ms to let a transient mount layout settle. */
+ startDelayMs = 0,
): boolean {
const [isIntersecting, setIntersecting] = useState(false);
@@ -23,16 +25,28 @@ export function useIntersectionObserver<T extends HTMLElement>(
}
}, options);
- if (currentReference) {
- observer.observe(currentReference);
+ const startObserving = (): void => {
+ if (currentReference) {
+ observer.observe(currentReference);
+ }
+ };
+
+ let timer: ReturnType<typeof setTimeout> | undefined;
+ if (startDelayMs > 0) {
+ timer = setTimeout(startObserving, startDelayMs);
+ } else {
+ startObserving();
}
return (): void => {
+ if (timer) {
+ clearTimeout(timer);
+ }
if (currentReference) {
observer.unobserve(currentReference);
}
};
- }, [ref, options, isObserverOnce]);
+ }, [ref, options, isObserverOnce, startDelayMs]);
return isIntersecting;
}
diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Panel/Panel.tsx b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Panel/Panel.tsx
index 0ba0d29059..a52312e098 100644
--- a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Panel/Panel.tsx
+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Panel/Panel.tsx
@@ -92,6 +92,7 @@ function Panel({
panelId={panelId}
data={data}
isFetching={isFetching}
+ isVisible={isVisible}
isPreviousData={isPreviousData}
error={error}
refetch={refetch}
diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Panel/PanelBody/PanelBody.tsx b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Panel/PanelBody/PanelBody.tsx
index 5a0ab2884a..cfe43db7bf 100644
--- a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Panel/PanelBody/PanelBody.tsx
+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Panel/PanelBody/PanelBody.tsx
@@ -23,6 +23,8 @@ interface PanelBodyProps {
panelId: string;
data: PanelQueryData;
isFetching: boolean;
+ /** Panel not yet scrolled into view — its fetch is deferred, so show the loader rather than NoData. */
+ isVisible?: boolean;
/** Showing a prior page's data while the next loads; forwarded so list renderers can show skeletons. */
isPreviousData?: boolean;
error: Error | null;
@@ -54,6 +56,7 @@ function PanelBody({
panelId,
data,
isFetching,
+ isVisible,
isPreviousData,
error,
refetch,
@@ -105,9 +108,9 @@ function PanelBody({
);
}
- // Full-panel loader only on first fetch; a refetch over existing data keeps the renderer
- // mounted (e.g. list page change). A refetch over empty data loads via NoData.
- if (isFetching && !hasData) {
+ // Full-panel loader on first fetch or while the fetch is deferred (off-screen); a refetch
+ // over existing data keeps the renderer mounted, empty data loads via NoData.
+ if ((isFetching || isVisible === false) && !hasData) {
return <PanelLoader />;
}
diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Panel/PanelBody/__tests__/PanelBody.test.tsx b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Panel/PanelBody/__tests__/PanelBody.test.tsx
index d32d3b0ff3..c889fc2868 100644
--- a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Panel/PanelBody/__tests__/PanelBody.test.tsx
+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Panel/PanelBody/__tests__/PanelBody.test.tsx
@@ -79,6 +79,21 @@ describe('PanelBody', () => {
expect(screen.queryByTestId('mock-renderer')).not.toBeInTheDocument();
});
+ it('shows the loader while the fetch is deferred (panel not yet scrolled into view)', () => {
+ render(
+ <PanelBody
+ {...baseProps}
+ panel={runnablePanel()}
+ data={{} as PanelQueryData}
+ isFetching={false}
+ isVisible={false}
+ />,
+ );
+
+ expect(screen.getByTestId('panel-loading')).toBeInTheDocument();
+ expect(screen.queryByTestId('mock-renderer')).not.toBeInTheDocument();
+ });
+
it('keeps the renderer mounted during a refetch over existing data (e.g. list page change)', () => {
render(
<PanelBody
diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Panel/ViewPanelModal/ViewPanelModalHeader.tsx b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Panel/ViewPanelModal/ViewPanelModalHeader.tsx
index 24beaea3e7..08c4104fa5 100644
--- a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Panel/ViewPanelModal/ViewPanelModalHeader.tsx
+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Panel/ViewPanelModal/ViewPanelModalHeader.tsx
@@ -113,8 +113,8 @@ function ViewPanelModalHeader({
/>
<Button
size="icon"
- variant="solid"
- color="primary"
+ variant="outlined"
+ color="secondary"
onClick={onRefresh}
disabled={isFetching}
aria-label="Refresh"
diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Section/SectionGrid/SectionGrid.tsx b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Section/SectionGrid/SectionGrid.tsx
index 6910f80ad4..874cbfcbee 100644
--- a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Section/SectionGrid/SectionGrid.tsx
+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Section/SectionGrid/SectionGrid.tsx
@@ -22,6 +22,7 @@ function SectionGrid({
sections,
}: SectionGridProps): JSX.Element {
const isEditable = useDashboardStore((s) => s.isEditable);
+
const rglLayout = useMemo<Layout[]>(
() =>
items.map((item) => ({
diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Section/SectionGrid/SectionGridItem.tsx b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Section/SectionGrid/SectionGridItem.tsx
index 172fb63d73..3ce1e18157 100644
--- a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Section/SectionGrid/SectionGridItem.tsx
+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Section/SectionGrid/SectionGridItem.tsx
@@ -10,6 +10,10 @@ const VIEWPORT_OBSERVER_OPTIONS: IntersectionObserverInit = {
rootMargin: '200px',
};
+// Start observing after RGL's mount unfold settles, so transient off-screen
+// panels don't latch as visible.
+const OBSERVER_START_DELAY_MS = 350;
+
interface SectionGridItemProps {
panel: DashboardtypesPanelDTO;
panelId: string;
@@ -31,6 +35,7 @@ function SectionGridItem({
containerRef,
VIEWPORT_OBSERVER_OPTIONS,
true,
+ OBSERVER_START_DELAY_MS,
);
useScrollIntoView(panelId, containerRef);
diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Section/hooks/__tests__/useScrollIntoView.test.ts b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Section/hooks/__tests__/useScrollIntoView.test.ts
index 85fe4c75bd..3ba88fbe52 100644
--- a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Section/hooks/__tests__/useScrollIntoView.test.ts
+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Section/hooks/__tests__/useScrollIntoView.test.ts
@@ -23,7 +23,7 @@ describe('useScrollIntoView', () => {
expect(scrollIntoView).toHaveBeenCalledWith({
behavior: 'smooth',
- block: 'start',
+ block: 'center',
});
expect(useScrollIntoViewStore.getState().scrollTargetId).toBeNull();
});
@@ -38,7 +38,7 @@ describe('useScrollIntoView', () => {
expect(scrollIntoView).toHaveBeenCalledWith({
behavior: 'smooth',
- block: 'start',
+ block: 'center',
});
expect(useScrollIntoViewStore.getState().scrollTargetId).toBeNull();
});
diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Section/hooks/useScrollIntoView.ts b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Section/hooks/useScrollIntoView.ts
index cac5dd8e46..1448e7d8a8 100644
--- a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Section/hooks/useScrollIntoView.ts
+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Section/hooks/useScrollIntoView.ts
@@ -9,7 +9,7 @@ import { useScrollIntoViewStore } from '../../../store/useScrollIntoViewStore';
export function useScrollIntoView(
id: string,
ref: RefObject<HTMLElement>,
- block: ScrollLogicalPosition = 'start',
+ block: ScrollLogicalPosition = 'center',
): void {
const scrollTargetId = useScrollIntoViewStore((s) => s.scrollTargetId);
const setScrollTargetId = useScrollIntoViewStore((s) => s.setScrollTargetId);
diff --git a/frontend/src/periscope/components/ContextMenu/index.tsx b/frontend/src/periscope/components/ContextMenu/index.tsx
index 333c36d988..142782d235 100644
--- a/frontend/src/periscope/components/ContextMenu/index.tsx
+++ b/frontend/src/periscope/components/ContextMenu/index.tsx
@@ -107,6 +107,9 @@ export function ContextMenu({
}
}}
trigger="click"
+ // Anchor to body (like the backdrop), not the host container: a modal's
+ // transformed dialog would break `position: fixed` and trap the menu below it.
+ getPopupContainer={(): HTMLElement => document.body}
overlayStyle={{
position: 'fixed',
left: position.left,
diff --git a/frontend/src/periscope/components/ContextMenu/styles.scss b/frontend/src/periscope/components/ContextMenu/styles.scss
index 503930ff71..f85fa386c5 100644
--- a/frontend/src/periscope/components/ContextMenu/styles.scss
+++ b/frontend/src/periscope/components/ContextMenu/styles.scss
@@ -77,6 +77,11 @@
color: var(--muted-foreground);
}
+// Body-portaled overlay: stay clickable when a modal sets `body { pointer-events: none }`.
+.context-menu {
+ pointer-events: auto;
+}
+
.context-menu .ant-popover-inner {
padding: 0;
border-radius: 6px;