Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .changeset/fuzzy-tables-focus.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@gradio/dataframe": patch
"@gradio/upload": patch
"gradio": patch
---

Prevent Dataframe container elements from adding whole-table stops to keyboard navigation.
31 changes: 31 additions & 0 deletions js/dataframe/Dataframe.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
waitFor,
within
} from "@self/tootils/render";
import { run_shared_prop_tests } from "@self/tootils/shared-prop-tests";
import { tick } from "svelte";

import Dataframe from "./Index.svelte";
Expand Down Expand Up @@ -37,6 +38,15 @@ const default_props = {
max_height: 500
};

run_shared_prop_tests({
component: Dataframe,
name: "Dataframe",
base_props: default_props,
// Dataframe renders visible and screen-reader label copies; targeted tests below cover its label behavior.
has_label: false,
has_validation_error: false
});

function get_cell(container: HTMLElement, row: number, col: number) {
return container.querySelector(
`[data-row='${row}'][data-col='${col}']`
Expand Down Expand Up @@ -64,6 +74,27 @@ async function wait(ms = 50) {
describe("Dataframe rendering", () => {
afterEach(() => cleanup());

test("tabbing skips dataframe containers and reaches individual cells", async () => {
const { getAllByRole, getByRole } = await render(Dataframe, default_props);

await waitFor(() => {
expect(getByRole("button", { name: "Alice" })).toBeVisible();
});

expect(getAllByRole("grid").every((grid) => grid.tabIndex === -1)).toBe(
true
);
expect(
getByRole("button", {
name: "dataframe.drop_to_upload"
})
).toHaveAttribute("tabindex", "-1");
expect(getByRole("button", { name: "Alice" })).toHaveAttribute(
"tabindex",
"0"
);
});

test("renders provided headers", async () => {
const { container } = await render(Dataframe, default_props);
await wait();
Expand Down
2 changes: 1 addition & 1 deletion js/dataframe/shared/Table.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -947,7 +947,7 @@
class:menu-open={active_cell_menu || active_header_menu}
onkeydown={handle_keydown}
role="grid"
tabindex="0"
tabindex="-1"
style="--df-max-col-width: {viewport_width}px;"
>
<Upload
Expand Down
2 changes: 1 addition & 1 deletion js/upload/src/Upload.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@
? height + "px"
: height
: "100%"}
tabindex={hidden ? -1 : 0}
tabindex={hidden || disable_click ? -1 : 0}
use:drag={{
on_drag_change: (d) => (dragging = d),
on_files: (files) => load_files_from_upload(files),
Expand Down
Loading