Skip to content

armgit / Pulse

Public Imported from GitHub
0

Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.

Keep wrapped filter actions viewport-safe

rcourtman7f8f53f2f4a6
diff --git a/docs/release-control/v6/internal/subsystems/frontend-primitives.md b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
index 8c9752f103..b247b9f5b7 100644
--- a/docs/release-control/v6/internal/subsystems/frontend-primitives.md
+++ b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
@@ -273,7 +273,14 @@ work extends shared components instead of creating new local variants.
adjacent product vocabulary. Table-mode segmented controls that expose a
grouping accessible label must use the shared `Group by` casing, while
visible options describe the mode itself (`Grouped`, `List`, or the
- owning surface's equivalent) instead of resource-specific concepts.
+ owning surface's equivalent) instead of resource-specific concepts. Shared
+ `PageControls` owns trailing filter-row actions such as utility buttons,
+ Columns, and Reset; those controls must stay grouped at the row end when
+ dense toolbars wrap so popovers remain viewport-safe instead of drifting
+ off-screen from page-local flex behavior. Shared `FilterToolbarPanel` owns
+ default filter-popover geometry, while narrow consumers such as
+ `ColumnPicker` must opt into their panel width through that primitive rather
+ than layering competing width classes page by page.
4. Add guardrail tests when a new shared pattern is introduced.
Shared monitored-system warning primitives must prove their admission-freeze
posture through the canonical `frontend-modern/src/utils/monitoredSystemPresentation.ts`
diff --git a/frontend-modern/src/components/shared/ColumnPicker.test.tsx b/frontend-modern/src/components/shared/ColumnPicker.test.tsx
index eff94817d5..cefe47d99f 100644
--- a/frontend-modern/src/components/shared/ColumnPicker.test.tsx
+++ b/frontend-modern/src/components/shared/ColumnPicker.test.tsx
@@ -13,6 +13,7 @@ describe('ColumnPicker', () => {
it('keeps column picker on shell, runtime, and model owners', () => {
expect(columnPickerSource).toContain('useColumnPickerState');
expect(columnPickerSource).toContain('COLUMN_PICKER_PANEL_TITLE');
+ expect(columnPickerSource).toContain('widthClass="w-56 max-w-[calc(100vw-2rem)]"');
expect(columnPickerSource).not.toContain('createSignal');
expect(columnPickerSource).not.toContain('createEffect');
expect(columnPickerSource).not.toContain('document.addEventListener');
@@ -69,9 +70,7 @@ describe('ColumnPicker', () => {
/>
));
- expect(
- screen.getByRole('button', { name: /columns 2 hidden/i }),
- ).toBeInTheDocument();
+ expect(screen.getByRole('button', { name: /columns 2 hidden/i })).toBeInTheDocument();
expect(screen.getByText('2 hidden')).toBeInTheDocument();
});
diff --git a/frontend-modern/src/components/shared/ColumnPicker.tsx b/frontend-modern/src/components/shared/ColumnPicker.tsx
index c0e9e57ee4..de2c0752c7 100644
--- a/frontend-modern/src/components/shared/ColumnPicker.tsx
+++ b/frontend-modern/src/components/shared/ColumnPicker.tsx
@@ -44,7 +44,10 @@ export const ColumnPicker: Component<ColumnPickerProps> = (props) => {
</FilterActionButton>
<Show when={state.isOpen()}>
- <FilterToolbarPanel class="top-[calc(100%+0.25rem)] z-50 w-56 p-0">
+ <FilterToolbarPanel
+ widthClass="w-56 max-w-[calc(100vw-2rem)]"
+ class="top-[calc(100%+0.25rem)] z-50 p-0"
+ >
<div class="px-3 py-2 border-b border-border-subtle">
<div class="flex items-center justify-between">
<span class="text-xs font-medium text-base-content">{COLUMN_PICKER_PANEL_TITLE}</span>
@@ -79,9 +82,7 @@ export const ColumnPicker: Component<ColumnPickerProps> = (props) => {
</div>
<Show when={props.columns.length === 0}>
- <div class="px-3 py-4 text-xs text-muted text-center">
- {COLUMN_PICKER_EMPTY_LABEL}
- </div>
+ <div class="px-3 py-4 text-xs text-muted text-center">{COLUMN_PICKER_EMPTY_LABEL}</div>
</Show>
</FilterToolbarPanel>
</Show>
diff --git a/frontend-modern/src/components/shared/FilterToolbar.test.tsx b/frontend-modern/src/components/shared/FilterToolbar.test.tsx
index b38de2eb7f..3e88a62d6e 100644
--- a/frontend-modern/src/components/shared/FilterToolbar.test.tsx
+++ b/frontend-modern/src/components/shared/FilterToolbar.test.tsx
@@ -3,8 +3,10 @@ import { For, createSignal } from 'solid-js';
import { afterEach, describe, expect, it, vi } from 'vitest';
import {
FilterHeader,
+ FilterToolbarPanel,
FilterSegmentedControl,
LabeledFilterSelect,
+ filterPanelDefaultWidthClass,
filterPanelClass,
} from './FilterToolbar';
import toggleSource from './Toggle.tsx?raw';
@@ -84,7 +86,9 @@ describe('FilterHeader', () => {
Load options
</button>
<LabeledFilterSelect label="Platform" value="truenas" data-testid="platform-filter">
- <For each={options()}>{(option) => <option value={option.value}>{option.label}</option>}</For>
+ <For each={options()}>
+ {(option) => <option value={option.value}>{option.label}</option>}
+ </For>
</LabeledFilterSelect>
</>
));
@@ -103,6 +107,20 @@ describe('FilterHeader', () => {
it('keeps shared filter popovers above nested table and card shells', () => {
expect(filterPanelClass).toContain('absolute');
expect(filterPanelClass).toContain('z-[80]');
- expect(filterPanelClass).toContain('w-[min(40rem,calc(100vw-2rem))]');
+ expect(filterPanelClass).not.toContain('w-[min(40rem,calc(100vw-2rem))]');
+ expect(filterPanelDefaultWidthClass).toContain('w-[min(40rem,calc(100vw-2rem))]');
+ });
+
+ it('allows narrow shared popovers to opt out of the default wide panel width', () => {
+ render(() => (
+ <FilterToolbarPanel widthClass="w-56 max-w-[calc(100vw-2rem)]" data-testid="panel">
+ Panel
+ </FilterToolbarPanel>
+ ));
+
+ const panel = screen.getByTestId('panel');
+ expect(panel).toHaveClass('w-56');
+ expect(panel).toHaveClass('max-w-[calc(100vw-2rem)]');
+ expect(panel).not.toHaveClass('w-[min(40rem,calc(100vw-2rem))]');
});
});
diff --git a/frontend-modern/src/components/shared/FilterToolbar.tsx b/frontend-modern/src/components/shared/FilterToolbar.tsx
index 5051983ae9..571f9f99af 100644
--- a/frontend-modern/src/components/shared/FilterToolbar.tsx
+++ b/frontend-modern/src/components/shared/FilterToolbar.tsx
@@ -17,7 +17,8 @@ export const filterSelectClass =
'rounded-md border border-border bg-surface px-2 py-1 text-xs font-medium text-base-content outline-none focus:border-blue-500';
export const filterDividerClass = 'hidden h-5 w-px bg-surface-hover sm:block';
export const filterPanelClass =
- 'absolute right-0 top-[calc(100%+0.5rem)] z-[80] w-[min(40rem,calc(100vw-2rem))] rounded-md border border-border bg-surface p-3 shadow-lg';
+ 'absolute right-0 top-[calc(100%+0.5rem)] z-[80] rounded-md border border-border bg-surface p-3 shadow-lg';
+export const filterPanelDefaultWidthClass = 'w-[min(40rem,calc(100vw-2rem))]';
export const filterPanelTitleClass = 'text-sm font-medium text-base-content';
export const filterPanelDescriptionClass = 'text-xs text-muted';
export const mobileFiltersButtonClass =
@@ -319,12 +320,18 @@ export const FilterActionButton: Component<FilterActionButtonProps> = (props) =>
interface FilterToolbarPanelProps extends JSX.HTMLAttributes<HTMLDivElement> {
children: JSX.Element;
+ widthClass?: string;
}
export const FilterToolbarPanel: Component<FilterToolbarPanelProps> = (props) => {
- const [local, divProps] = splitProps(props, ['children', 'class']);
+ const [local, divProps] = splitProps(props, ['children', 'class', 'widthClass']);
return (
- <div {...divProps} class={`${filterPanelClass} ${local.class ?? ''}`.trim()}>
+ <div
+ {...divProps}
+ class={`${filterPanelClass} ${local.widthClass ?? filterPanelDefaultWidthClass} ${
+ local.class ?? ''
+ }`.trim()}
+ >
{local.children}
</div>
);
diff --git a/frontend-modern/src/components/shared/PageControls.test.tsx b/frontend-modern/src/components/shared/PageControls.test.tsx
index 3b2b014106..3dc34f4ea8 100644
--- a/frontend-modern/src/components/shared/PageControls.test.tsx
+++ b/frontend-modern/src/components/shared/PageControls.test.tsx
@@ -31,8 +31,13 @@ describe('PageControls', () => {
expect(screen.getByTestId('search')).toBeInTheDocument();
expect(screen.getByRole('button', { name: /filters/i })).toBeInTheDocument();
- expect(screen.getByRole('button', { name: /columns/i })).toBeInTheDocument();
- expect(screen.getByRole('button', { name: /reset all/i })).toBeInTheDocument();
+ const columnsButton = screen.getByRole('button', { name: /columns/i });
+ const resetButton = screen.getByRole('button', { name: /reset all/i });
+ expect(columnsButton).toBeInTheDocument();
+ expect(resetButton).toBeInTheDocument();
+ const trailingActions = columnsButton.closest('.ml-auto');
+ expect(trailingActions).not.toBeNull();
+ expect(trailingActions!).toContainElement(resetButton);
fireEvent.click(screen.getByRole('button', { name: /filters/i }));
expect(onToggleFilters).toHaveBeenCalledTimes(1);
diff --git a/frontend-modern/src/components/shared/PageControls.tsx b/frontend-modern/src/components/shared/PageControls.tsx
index aaca6a83d5..c6670755ae 100644
--- a/frontend-modern/src/components/shared/PageControls.tsx
+++ b/frontend-modern/src/components/shared/PageControls.tsx
@@ -79,6 +79,11 @@ export const PageControls: Component<PageControlsProps> = (props) => {
const activeMobileTrailing = () => (mobileControlsEnabled() ? local.mobileTrailing : undefined);
const activeUtilityActions = () => (mobileControlsEnabled() ? undefined : local.utilityActions);
const activeSearchTrailing = () => (mobileControlsEnabled() ? undefined : local.searchTrailing);
+ const showColumnVisibility = () =>
+ Boolean(local.columnVisibility && local.columnVisibility.availableToggles().length > 0);
+ const showResetAction = () => local.resetAction?.show === true;
+ const hasTrailingActions = () =>
+ Boolean(activeUtilityActions() || showColumnVisibility() || showResetAction());
return (
<FilterHeader
@@ -97,33 +102,35 @@ export const PageControls: Component<PageControlsProps> = (props) => {
>
{local.children}
- <Show when={activeUtilityActions()}>
- <FilterDivider />
- {activeUtilityActions()}
- </Show>
+ <Show when={hasTrailingActions()}>
+ <div class="ml-auto inline-flex flex-wrap items-center gap-2">
+ <Show when={activeUtilityActions()}>
+ <FilterDivider />
+ {activeUtilityActions()}
+ </Show>
- <Show
- when={local.columnVisibility && local.columnVisibility.availableToggles().length > 0}
- >
- <FilterDivider />
- <ColumnPicker
- columns={local.columnVisibility!.availableToggles()}
- isHidden={local.columnVisibility!.isHiddenByUser}
- onToggle={local.columnVisibility!.toggle}
- onReset={local.columnVisibility!.resetToDefaults}
- />
- </Show>
+ <Show when={showColumnVisibility()}>
+ <FilterDivider />
+ <ColumnPicker
+ columns={local.columnVisibility!.availableToggles()}
+ isHidden={local.columnVisibility!.isHiddenByUser}
+ onToggle={local.columnVisibility!.toggle}
+ onReset={local.columnVisibility!.resetToDefaults}
+ />
+ </Show>
- <Show when={local.resetAction?.show}>
- <FilterDivider />
- <FilterActionButton
- onClick={() => local.resetAction?.onClick()}
- title={local.resetAction?.title}
- class={local.resetAction?.class}
- >
- {local.resetAction?.icon}
- {local.resetAction?.label ?? 'Reset'}
- </FilterActionButton>
+ <Show when={showResetAction()}>
+ <FilterDivider />
+ <FilterActionButton
+ onClick={() => local.resetAction?.onClick()}
+ title={local.resetAction?.title}
+ class={local.resetAction?.class}
+ >
+ {local.resetAction?.icon}
+ {local.resetAction?.label ?? 'Reset'}
+ </FilterActionButton>
+ </Show>
+ </div>
</Show>
</FilterHeader>
);