Skip to content

Commit 8e40c15

Browse files
Implement multiple cell selection (#10456)
* add group cell selection logic * hide cell menu button when selected cells > 1 * add delete values logic * add changeset * maintain tab navigation * tweak * add interaction story * fix test * * copy selected cells * delete and backspace for deletion * move funcs to utils file * fix test --------- Co-authored-by: gradio-pr-bot <[email protected]>
1 parent 39f0c23 commit 8e40c15

File tree

6 files changed

+692
-338
lines changed

6 files changed

+692
-338
lines changed

.changeset/eleven-files-prove.md

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@gradio/dataframe": minor
3+
"gradio": minor
4+
---
5+
6+
feat:Implement multiple cell selection

js/dataframe/Dataframe.stories.svelte

+47-5
Original file line numberDiff line numberDiff line change
@@ -200,9 +200,11 @@
200200
const canvas = within(canvasElement);
201201

202202
const cell_400 = canvas.getAllByRole("cell")[5];
203-
userEvent.click(cell_400);
203+
await userEvent.click(cell_400);
204204

205-
const open_dialog_btn = within(cell_400).getByText("");
205+
const open_dialog_btn = await within(cell_400).findByRole("button", {
206+
name: ""
207+
});
206208
await userEvent.click(open_dialog_btn);
207209

208210
const add_row_btn = canvas.getByText("Add row above");
@@ -227,12 +229,52 @@
227229
}}
228230
/>
229231

232+
<Story
233+
name="Dataframe with multiple selection interactions"
234+
args={{
235+
values: [
236+
[1, 2, 3, 4],
237+
[5, 6, 7, 8],
238+
[9, 10, 11, 12],
239+
[13, 14, 15, 16]
240+
],
241+
col_count: [4, "dynamic"],
242+
row_count: [4, "dynamic"],
243+
headers: ["A", "B", "C", "D"],
244+
editable: true
245+
}}
246+
play={async ({ canvasElement }) => {
247+
const canvas = within(canvasElement);
248+
const cells = canvas.getAllByRole("cell");
249+
const user = userEvent.setup();
250+
251+
// cmd+click to select non-contiguous cells
252+
await user.keyboard("[MetaLeft>]");
253+
await user.click(cells[4]);
254+
await user.click(cells[6]);
255+
await user.click(cells[2]);
256+
await user.keyboard("[/MetaLeft]");
257+
258+
// shift+click to select a range
259+
await user.keyboard("[ShiftLeft>]");
260+
await user.click(cells[7]);
261+
await user.click(cells[6]);
262+
await user.keyboard("[/ShiftLeft]");
263+
264+
// clear selected cells
265+
await user.keyboard("{Delete}");
266+
267+
// verify cells were cleared by clicking one
268+
await user.click(cells[2]);
269+
}}
270+
/>
271+
230272
<Story
231273
name="Dataframe toolbar interactions"
232274
args={{
233275
col_count: [3, "dynamic"],
234276
row_count: [2, "dynamic"],
235-
headers: ["Math", "Reading", "Writifdsfsng"],
277+
headers: ["Math", "Reading", "Writing"],
236278
values: [
237279
[800, 100, 400],
238280
[200, 800, 700]
@@ -244,12 +286,12 @@
244286
const canvas = within(canvasElement);
245287

246288
const copy_button = canvas.getByRole("button", {
247-
name: /copy table data/i
289+
name: "Copy table data"
248290
});
249291
await userEvent.click(copy_button);
250292

251293
const fullscreen_button = canvas.getByRole("button", {
252-
name: /enter fullscreen/i
294+
name: "Enter fullscreen"
253295
});
254296
await userEvent.click(fullscreen_button);
255297

0 commit comments

Comments
 (0)