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
fix: expand table export options by clicking the row (#11381)
Shahmir Varqhabd9ec89f8df1
diff --git a/frontend/src/components/data-table/__tests__/export-actions.test.tsx b/frontend/src/components/data-table/__tests__/export-actions.test.tsxindex 4bb21035d4..571af9cbfa 100644--- a/frontend/src/components/data-table/__tests__/export-actions.test.tsx+++ b/frontend/src/components/data-table/__tests__/export-actions.test.tsx@@ -914,6 +914,94 @@ describe("ExportActions dialog", () => {expect(within(dialog).queryByRole("group")).not.toBeInTheDocument();});+ it("describes format options with their description and current settings", async () => {+ renderExportActions({+ getExportMetadata: vi.fn().mockResolvedValue(geometryMetadata),+ });+ await openDialog();+ await screen.findByRole("button", { name: "GeoParquet options" });++ for (const [label, description] of [+ ["CSV", "Comma-separated values Comma · UTF-8"],+ ["TSV", "Best for Excel and Google Sheets UTF-8"],+ ["JSON", "Raw JSON data Escapes non-ASCII"],+ ["GeoParquet", "Parquet with geometry and CRS metadata location"],+ ["GeoJSON", "Geometry in longitude and latitude location"],+ ]) {+ expect(+ screen.getByRole("button", { name: `${label} options` }),+ ).toHaveAccessibleDescription(description);+ }++ const csvOptions = screen.getByRole("button", { name: "CSV options" });+ fireEvent.click(csvOptions);+ fireEvent.change(screen.getByRole("combobox", { name: "Delimiter" }), {+ target: { value: ";" },+ });+ expect(csvOptions).toHaveAccessibleDescription(+ "Comma-separated values Semicolon · UTF-8",+ );+ fireEvent.click(csvOptions);+ expect(csvOptions).toHaveAccessibleDescription(+ "Comma-separated values Semicolon · UTF-8",+ );+ });++ it.each([+ ["CSV", "Comma-separated values"],+ ["TSV", "Best for Excel and Google Sheets"],+ ["JSON", "Raw JSON data"],+ ["GeoParquet", "Parquet with geometry and CRS metadata"],+ ["GeoJSON", "Geometry in longitude and latitude"],+ ])(+ "toggles %s options from the row label and description",+ async (label, description) => {+ renderExportActions({+ getExportMetadata: vi.fn().mockResolvedValue(geometryMetadata),+ });+ await openDialog();+ const toggle = await screen.findByRole("button", {+ name: `${label} options`,+ });++ fireEvent.click(screen.getByText(label));+ expect(toggle).toHaveAttribute("aria-expanded", "true");+ expect(+ screen.getByRole("group", { name: `${label} options` }),+ ).toBeInTheDocument();++ fireEvent.click(screen.getByText(description));+ expect(toggle).toHaveAttribute("aria-expanded", "false");+ expect(+ screen.queryByRole("group", { name: `${label} options` }),+ ).not.toBeInTheDocument();+ },+ );++ it("keeps download and copy independent of row expansion", async () => {+ vi.stubGlobal(+ "fetch",+ vi.fn().mockResolvedValue({+ ok: true,+ text: vi.fn().mockResolvedValue("name,value\n"),+ }),+ );+ renderExportActions();+ await openDialog();+ const toggle = screen.getByRole("button", { name: "CSV options" });++ fireEvent.click(screen.getByRole("button", { name: "Download CSV" }));+ await waitFor(() => expect(downloadByURL).toHaveBeenCalled());+ expect(toggle).toHaveAttribute("aria-expanded", "false");++ fireEvent.click(screen.getByText("CSV"));+ fireEvent.click(screen.getByRole("button", { name: "Copy CSV" }));+ expect(toggle).toHaveAttribute("aria-expanded", "true");+ await waitFor(() => {+ expect(copyToClipboard).toHaveBeenCalledWith("name,value\n");+ });+ });+it("sends only changed CSV options with a download", async () => {renderExportActions();await openDialog();diff --git a/frontend/src/components/data-table/export-actions.tsx b/frontend/src/components/data-table/export-actions.tsxindex 926245965a..2dc3d3d8ec 100644--- a/frontend/src/components/data-table/export-actions.tsx+++ b/frontend/src/components/data-table/export-actions.tsx@@ -761,7 +761,10 @@ export const ExportActions: React.FC<ExportActionProps> = (props) => {const expanded =configurableFormat !== null &&expandedFormat === configurableFormat;+ const FormatHeader = configurableFormat ? "button" : "div";const panelId = `export-options-${option.format}`;+ const descriptionId = `${panelId}-description`;+ const summaryId = `${panelId}-summary`;const rowFailure =failure?.action.format === option.format ? failure : null;const summary =@@ -802,55 +805,78 @@ export const ExportActions: React.FC<ExportActionProps> = (props) => {data-testid={`export-row-${option.format}`}className={cn(expanded && "bg-muted/40")}>- <div className="grid min-h-[60px] grid-cols-[28px_minmax(0,1fr)_auto] items-center gap-x-1 px-2.5 py-2 hover:bg-accent/50">- {configurableFormat ? (- <Button- type="button"- variant="ghost"- size="icon"- aria-label={`${optionLabel} options`}- aria-expanded={expanded}- aria-controls={panelId}- onClick={() => toggleExpanded(option.format)}+ <div className="grid grid-cols-[minmax(0,1fr)_auto] items-center hover:bg-accent/50">+ <FormatHeader+ type={configurableFormat ? "button" : undefined}+ className={cn(+ "grid min-h-[60px] min-w-0 grid-cols-[28px_minmax(0,1fr)] items-center gap-x-1 py-2 pl-2.5 pr-1 text-left",+ configurableFormat &&+ "cursor-pointer focus-visible:outline-hidden focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-ring",+ )}+ aria-label={+ configurableFormat ? `${optionLabel} options` : undefined+ }+ aria-describedby={+ configurableFormat+ ? [descriptionId, summary && summaryId]+ .filter(Boolean)+ .join(" ")+ : undefined+ }+ aria-expanded={configurableFormat ? expanded : undefined}+ aria-controls={configurableFormat ? panelId : undefined}+ onClick={+ configurableFormat+ ? () => toggleExpanded(option.format)+ : undefined+ }+ >+ <span+ aria-hidden={true}+ className="inline-flex h-6 w-6 items-center justify-center">- <ChevronRightIcon- className={cn(- "h-4 w-4 text-muted-foreground transition-transform",- expanded && "rotate-90",- )}+ {configurableFormat && (+ <ChevronRightIcon+ className={cn(+ "h-4 w-4 text-muted-foreground transition-transform",+ expanded && "rotate-90",+ )}+ />+ )}+ </span>+ <span className="flex min-w-0 items-center gap-3 pl-1">+ <option.icon+ aria-hidden={true}+ data-testid={`export-format-icon-${option.format}`}+ className="h-4 w-4 shrink-0 text-muted-foreground"/>- </Button>- ) : (- <span aria-hidden={true} className="h-6 w-6" />- )}- <div className="flex min-w-0 items-center gap-3 pl-1">- <option.icon- aria-hidden={true}- data-testid={`export-format-icon-${option.format}`}- className="h-4 w-4 shrink-0 text-muted-foreground"- />- <div className="grid min-w-0 gap-1">- <span className="flex min-w-0 items-baseline gap-x-2">- <span className="text-sm font-medium leading-tight">- {optionLabel}- </span>- {summary && (- <span- data-testid={`export-summary-${option.format}`}- className="min-w-0 truncate text-xs text-muted-foreground"- >- {summary}+ <span className="grid min-w-0 gap-1">+ <span className="flex min-w-0 items-baseline gap-x-2">+ <span className="text-sm font-medium leading-tight">+ {optionLabel}</span>- )}- </span>- <span className="text-xs text-muted-foreground leading-tight">- {option.format === "parquet" && hasGeometry- ? "Parquet with geometry and CRS metadata"- : option.description}+ {summary && (+ <span+ id={summaryId}+ data-testid={`export-summary-${option.format}`}+ className="min-w-0 truncate text-xs text-muted-foreground"+ >+ {summary}+ </span>+ )}+ </span>+ <span+ id={descriptionId}+ className="text-xs text-muted-foreground leading-tight"+ >+ {option.format === "parquet" && hasGeometry+ ? "Parquet with geometry and CRS metadata"+ : option.description}+ </span></span>- </div>- </div>- <div className="flex items-center gap-0.5">+ </span>+ </FormatHeader>+ <div className="flex items-center gap-0.5 pr-2.5"><Tooltipcontent={option.canDownload