Compare commits

...

1 Commits

Author SHA1 Message Date
Evan
1d1d734073 fix(embedded): respect show_filters URL param in standalone report mode
Report mode (standalone=3) unconditionally hides the filter bar via
hidden={isReport}, since it's meant for one-shot screenshot renders
(reports, thumbnails). Embedded SDK consumers also use standalone=3 to
hide the title/tab/nav (hideTitle + hideTab both map into that bitmask),
but may still want the filter bar visible via
dashboardUiConfig.filters.visible, which maps to the show_filters URL
param. That param was declared in URL_PARAMS but never actually wired
up, so it was silently ignored, breaking embedded dashboards that
wanted filters visible while hiding chrome.

hideFilterBar now only forces the filter bar hidden in report mode when
show_filters isn't explicitly set to true, so report-mode defaults are
unchanged but embedded consumers can override them.

Fixes #30630
2026-07-22 04:17:48 -07:00
2 changed files with 79 additions and 4 deletions

View File

@@ -566,6 +566,73 @@ describe('DashboardBuilder', () => {
expect(queryByTestId('dashboard-filters-panel')).not.toBeInTheDocument();
});
test('should hide the vertical filter bar in report mode (?standalone=3)', () => {
const originalHref = window.location.href;
window.history.replaceState({}, '', '/?standalone=3');
jest.spyOn(useNativeFiltersModule, 'useNativeFilters').mockReturnValue({
showDashboard: true,
missingInitialFilters: [],
dashboardFiltersOpen: true,
toggleDashboardFiltersOpen: jest.fn(),
nativeFiltersEnabled: true,
});
try {
const { getByTestId } = setup();
expect(getByTestId('dashboard-filters-panel')).toHaveStyleRule(
'display',
'none',
);
} finally {
window.history.replaceState({}, '', originalHref);
}
});
test('should reveal the vertical filter bar in report mode when embedded ?show_filters=true is set (issue #30630)', () => {
// Regression test for #30630: embedded dashboards use ?standalone=3 to hide
// the title/tabs/nav, but that also forced isReport=true, which unconditionally
// hid the filter bar even when the Embedded SDK's dashboardUiConfig.filters.visible
// (mapped to the show_filters URL param) explicitly asked for filters to show.
const originalHref = window.location.href;
window.history.replaceState({}, '', '/?standalone=3&show_filters=true');
jest.spyOn(useNativeFiltersModule, 'useNativeFilters').mockReturnValue({
showDashboard: true,
missingInitialFilters: [],
dashboardFiltersOpen: true,
toggleDashboardFiltersOpen: jest.fn(),
nativeFiltersEnabled: true,
});
try {
const { getByTestId } = setup();
expect(getByTestId('dashboard-filters-panel')).not.toHaveStyleRule(
'display',
'none',
);
} finally {
window.history.replaceState({}, '', originalHref);
}
});
test('should keep the filter bar hidden in report mode when ?show_filters=false is set', () => {
const originalHref = window.location.href;
window.history.replaceState({}, '', '/?standalone=3&show_filters=false');
jest.spyOn(useNativeFiltersModule, 'useNativeFilters').mockReturnValue({
showDashboard: true,
missingInitialFilters: [],
dashboardFiltersOpen: true,
toggleDashboardFiltersOpen: jest.fn(),
nativeFiltersEnabled: true,
});
try {
const { getByTestId } = setup();
expect(getByTestId('dashboard-filters-panel')).toHaveStyleRule(
'display',
'none',
);
} finally {
window.history.replaceState({}, '', originalHref);
}
});
});
test('should render ParentSize wrapper with height 100% for tabs', async () => {

View File

@@ -427,6 +427,14 @@ const DashboardBuilder = () => {
: undefined;
const standaloneMode = getUrlParam(URL_PARAMS.standalone);
const isReport = standaloneMode === DashboardStandaloneMode.Report;
// Report mode (standalone=3) hides the filter bar by default, since it's used
// for one-shot screenshot renders (email reports, thumbnails). Embedded SDK
// consumers also use standalone=3 to hide the title/tabs/nav, but may still
// want filters visible via dashboardUiConfig.filters.visible, which maps to
// the show_filters URL param. An explicit show_filters=true overrides the
// report-mode default so the filter bar stays visible.
const showFiltersUrlParam = getUrlParam(URL_PARAMS.showFilters);
const hideFilterBar = isReport && showFiltersUrlParam !== true;
const hideDashboardHeader =
uiConfig.hideTitle ||
standaloneMode === DashboardStandaloneMode.HideNavAndTitle ||
@@ -528,12 +536,12 @@ const DashboardBuilder = () => {
filterBarOrientation === FilterBarOrientation.Horizontal && (
<FilterBar
orientation={FilterBarOrientation.Horizontal}
hidden={isReport}
hidden={hideFilterBar}
/>
)}
</>
),
[hideDashboardHeader, showFilterBar, filterBarOrientation, isReport],
[hideDashboardHeader, showFilterBar, filterBarOrientation, hideFilterBar],
);
const renderDraggableContent = useCallback(
@@ -595,7 +603,7 @@ const DashboardBuilder = () => {
return (
<FiltersPanel
width={filterBarWidth}
hidden={isReport}
hidden={hideFilterBar}
data-test="dashboard-filters-panel"
>
<StickyPanel ref={containerRef} width={filterBarWidth}>
@@ -620,7 +628,7 @@ const DashboardBuilder = () => {
toggleDashboardFiltersOpen,
filterBarHeight,
filterBarOffset,
isReport,
hideFilterBar,
],
);