A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.
Python artificial-intelligencedagdata-sciencedata-visualizationdataflowdeveloper-toolsmachine-learningnotebookspipelinepythonreactivesqlweb-app
feat(table): add "Hide all" columns action (#10068)
Kiran Gadhavefccf378881a0
diff --git a/frontend/src/components/data-table/__tests__/column-explorer.test.tsx b/frontend/src/components/data-table/__tests__/column-explorer.test.tsxindex bf4f2f492b..f9d8cf56fe 100644--- a/frontend/src/components/data-table/__tests__/column-explorer.test.tsx+++ b/frontend/src/components/data-table/__tests__/column-explorer.test.tsx@@ -126,3 +126,28 @@ describe("ColumnExplorerPanel header counts", () => {expect(screen.queryByText(/hidden/)).not.toBeInTheDocument();});});++describe("ColumnExplorerPanel visibility actions", () => {+ const showAll = () => screen.getByRole("button", { name: /Show all/ });+ const hideAll = () => screen.getByRole("button", { name: /Hide all/ });++ it("disables 'Show all' when every column is visible", () => {+ renderPanel();+ expect(showAll()).toBeDisabled();+ expect(hideAll()).toBeEnabled();+ });++ it("disables 'Hide all' when every column is hidden", () => {+ renderPanel({+ initiallyHidden: ["customer_name", "cust_age", "order_total"],+ });+ expect(showAll()).toBeEnabled();+ expect(hideAll()).toBeDisabled();+ });++ it("enables both actions when some columns are hidden", () => {+ renderPanel({ initiallyHidden: ["cust_age"] });+ expect(showAll()).toBeEnabled();+ expect(hideAll()).toBeEnabled();+ });+});diff --git a/frontend/src/components/data-table/__tests__/column-visibility-dropdown.test.tsx b/frontend/src/components/data-table/__tests__/column-visibility-dropdown.test.tsxindex 4a73c6daa5..c57ec721fd 100644--- a/frontend/src/components/data-table/__tests__/column-visibility-dropdown.test.tsx+++ b/frontend/src/components/data-table/__tests__/column-visibility-dropdown.test.tsx@@ -21,10 +21,17 @@ beforeAll(() => {type Row = Record<string, unknown>;+// Select, index, and nameless columns are non-hideable in production+// (see columns.tsx), so the harness mirrors that to keep visibility counts+// aligned with the real table.const TEST_COLUMNS: ColumnDef<Row>[] = [- { id: SELECT_COLUMN_ID, accessorKey: SELECT_COLUMN_ID },- { id: INDEX_COLUMN_NAME, accessorKey: INDEX_COLUMN_NAME },- { id: "__m_column__0", accessorKey: "__m_column__0" },+ { id: SELECT_COLUMN_ID, accessorKey: SELECT_COLUMN_ID, enableHiding: false },+ {+ id: INDEX_COLUMN_NAME,+ accessorKey: INDEX_COLUMN_NAME,+ enableHiding: false,+ },+ { id: "__m_column__0", accessorKey: "__m_column__0", enableHiding: false },{id: "customer_name",accessorKey: "customer_name",@@ -101,6 +108,7 @@ describe("ColumnVisibilityDropdown", () => {renderAndOpen({ initiallyHidden: ["cust_age"] });expect(getOptionTexts()).toEqual(["Show all",+ "Hide all","cust_age","customer_name","order_total",@@ -117,6 +125,7 @@ describe("ColumnVisibilityDropdown", () => {expect(getOptionTexts()).toEqual(["Show all",+ "Hide all","cust_age","customer_name","order_total",@@ -132,6 +141,7 @@ describe("ColumnVisibilityDropdown", () => {fireEvent.click(getColumnOption("customer_name"));expect(getOptionTexts()).toEqual(["Show all",+ "Hide all","cust_age","customer_name","order_total",@@ -144,6 +154,7 @@ describe("ColumnVisibilityDropdown", () => {// Reopen sorts both hidden columns first, preserving table order.expect(getOptionTexts()).toEqual(["Show all",+ "Hide all","customer_name","cust_age","order_total",@@ -189,6 +200,52 @@ describe("ColumnVisibilityDropdown", () => {);});+ it("'Hide all' hides every hideable column", () => {+ renderAndOpen();+ fireEvent.click(getColumnOption("Hide all"));++ expect(+ getColumnOption("customer_name").querySelector(".lucide-eye-off"),+ ).not.toBeNull();+ expect(+ getColumnOption("cust_age").querySelector(".lucide-eye-off"),+ ).not.toBeNull();+ expect(+ getColumnOption("order_total").querySelector(".lucide-eye-off"),+ ).not.toBeNull();+ expect(getColumnOption("Hide all")).toHaveAttribute(+ "aria-disabled",+ "true",+ );+ });++ it("disables 'Hide all' when every column is already hidden", () => {+ renderAndOpen({+ initiallyHidden: ["customer_name", "cust_age", "order_total"],+ });+ expect(getColumnOption("Hide all")).toHaveAttribute(+ "aria-disabled",+ "true",+ );+ });++ it("'Hide all' leaves non-hideable columns visible", () => {+ renderAndOpen({ nonHideable: ["customer_name"] });+ fireEvent.click(getColumnOption("Hide all"));++ expect(+ getColumnOption("cust_age").querySelector(".lucide-eye-off"),+ ).not.toBeNull();+ const nonHideable = getColumnOption("customer_name");+ expect(nonHideable).toHaveAttribute("aria-disabled", "true");+ expect(nonHideable.querySelector(".lucide-eye-off")).toBeNull();+ // Every hideable column is now hidden, so the action gates off.+ expect(getColumnOption("Hide all")).toHaveAttribute(+ "aria-disabled",+ "true",+ );+ });+it("hides and shows matching columns via bulk actions while searching", () => {renderAndOpen();fireEvent.change(getSearchInput(), { target: { value: "cust" } });diff --git a/frontend/src/components/data-table/column-explorer-panel/column-explorer.tsx b/frontend/src/components/data-table/column-explorer-panel/column-explorer.tsxindex 88a15d45c7..c36cb0c21c 100644--- a/frontend/src/components/data-table/column-explorer-panel/column-explorer.tsx+++ b/frontend/src/components/data-table/column-explorer-panel/column-explorer.tsx@@ -50,7 +50,10 @@ import {import { smartMatch } from "@/utils/smartMatch";import type { Column, Table } from "@tanstack/react-table";import { cn } from "@/utils/cn";-import { getColumnCountForDisplay } from "../hooks/use-column-visibility";+import {+ getColumnCountForDisplay,+ getUserColumnVisibilityCounts,+} from "../hooks/use-column-visibility";interface ColumnExplorerPanelProps<TData> {previewColumn: PreviewColumn;@@ -90,6 +93,7 @@ export function ColumnExplorerPanel<TData>({totalColumns: effectiveTotalColumns,hiddenColumns: hiddenColumnCount,} = getColumnCountForDisplay(table, totalColumns);+ const { visible: visibleColumnCount } = getUserColumnVisibilityCounts(table);const { rowsAndColumns, hiddenSuffix } = prettifyRowColumnCount({numRows: totalRows,@@ -108,17 +112,34 @@ export function ColumnExplorerPanel<TData>({value={columns?.map(([columnName]) => columnName).join(",\n") || ""}className="h-3 w-3"/>- {hiddenColumnCount > 0 && (- <Button- type="button"- variant="link"- size="xs"- className="h-auto p-0"- onClick={() => table.resetColumnVisibility(true)}- >- Unhide all- </Button>- )}+ <div className="ml-auto flex items-center gap-1">+ <Tooltip content="Show all columns" delayDuration={400}>+ <Button+ type="button"+ variant="ghost"+ size="xs"+ className="gap-1"+ disabled={hiddenColumnCount === 0}+ onClick={() => table.toggleAllColumnsVisible(true)}+ >+ <EyeIcon className="w-3 h-3" />+ Show all+ </Button>+ </Tooltip>+ <Tooltip content="Hide all columns" delayDuration={400}>+ <Button+ type="button"+ variant="ghost"+ size="xs"+ className="gap-1"+ disabled={visibleColumnCount === 0}+ onClick={() => table.toggleAllColumnsVisible(false)}+ >+ <EyeOffIcon className="w-3 h-3" />+ Hide all+ </Button>+ </Tooltip>+ </div></div><Command className="h-5/6 bg-background" shouldFilter={false}><CommandInputdiff --git a/frontend/src/components/data-table/column-visibility-dropdown.tsx b/frontend/src/components/data-table/column-visibility-dropdown.tsxindex 09f92b57be..fdf7addbbc 100644--- a/frontend/src/components/data-table/column-visibility-dropdown.tsx+++ b/frontend/src/components/data-table/column-visibility-dropdown.tsx@@ -59,6 +59,12 @@ export const ColumnVisibilityDropdown = <TData,>({const hiddenIds = userColumns.filter((column) => !column.getIsVisible()).map((column) => column.id);+ const hideableIds = userColumns+ .filter((column) => column.getCanHide())+ .map((column) => column.id);+ const visibleHideableCount = hideableIds.filter(+ (id) => !hiddenIds.includes(id),+ ).length;const applyHidden = (next: string[] | string | null) => {const hidden = new Set(Array.isArray(next) ? next : []);@@ -127,6 +133,15 @@ export const ColumnVisibilityDropdown = <TData,>({<EyeIcon className="w-3 h-3 mr-1.5" />Show all</CommandItem>+ <CommandItem+ value="__hide_all__"+ disabled={visibleHideableCount === 0}+ onSelect={() => applyHidden(hideableIds)}+ className="cursor-pointer"+ >+ <EyeOffIcon className="w-3 h-3 mr-1.5" />+ Hide all+ </CommandItem><CommandSeparator /></>) : (