Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement multiple cell selection #10456

Merged
merged 16 commits into from
Feb 3, 2025
Merged

Implement multiple cell selection #10456

merged 16 commits into from
Feb 3, 2025

Conversation

hannahblair
Copy link
Collaborator

@hannahblair hannahblair commented Jan 28, 2025

Description

Allows you to select multiple cells in a dataframe. You can also press delete to clear their values.

  • If multiple cells are selected, you won't see the cell menu button. It doesn't look great when all the selected cells have the cell menu button visible (see screenshot) and I think it's redundant anyway.
Screenshot 2025-01-29 at 12 57 34
  • Shift click to select a group of cells and span the row or column to meet it

Kapture 2025-01-29 at 13 01 05

  • Cmd click to select multiple cells without expanding to the row or column to meet it

Kapture 2025-01-29 at 13 00 05

  • Press delete to clear all the values of the selected cells (see above)

  • This prefaces the select all cells in a column/row behaviour which will be in a separate PR.

Closes: #3283

🎯 PRs Should Target Issues

Before your create a PR, please check to see if there is an existing issue for this change. If not, please create an issue before you create this PR, unless the fix is very small.

Not adhering to this guideline will result in the PR being closed.

Testing and Formatting Your Code

  1. PRs will only be merged if tests pass on CI. We recommend at least running the backend tests locally, please set up your Gradio environment locally and run the backed tests: bash scripts/run_backend_tests.sh

  2. Please run these bash scripts to automatically format your code: bash scripts/format_backend.sh, and (if you made any changes to non-Python files) bash scripts/format_frontend.sh

@gradio-pr-bot
Copy link
Collaborator

gradio-pr-bot commented Jan 28, 2025

🪼 branch checks and previews

Name Status URL
Spaces ready! Spaces preview
Storybook ready! Storybook preview
🦄 Changes detected! Details

Install Gradio from this PR

pip install https://gradio-pypi-previews.s3.amazonaws.com/193188eca4d750aaff16ac24ff2ed081c002b476/gradio-5.14.0-py3-none-any.whl

Install Gradio Python Client from this PR

pip install "gradio-client @ git+https://github.com/gradio-app/gradio@193188eca4d750aaff16ac24ff2ed081c002b476#subdirectory=client/python"

Install Gradio JS Client from this PR

npm install https://gradio-npm-previews.s3.amazonaws.com/193188eca4d750aaff16ac24ff2ed081c002b476/gradio-client-1.10.0.tgz

Use Lite from this PR

<script type="module" src="https://gradio-lite-previews.s3.amazonaws.com/193188eca4d750aaff16ac24ff2ed081c002b476/dist/lite.js""></script>

@gradio-pr-bot
Copy link
Collaborator

gradio-pr-bot commented Jan 28, 2025

🦄 change detected

This Pull Request includes changes to the following packages.

Package Version
@gradio/dataframe minor
gradio minor
  • Maintainers can select this checkbox to manually select packages to update.

With the following changelog entry.

Implement multiple cell selection

Maintainers or the PR author can modify the PR title to modify this entry.

Something isn't right?

  • Maintainers can change the version label to modify the version bump.
  • If the bot has failed to detect any changes, or if this pull request needs to update multiple packages to different versions or requires a more comprehensive changelog entry, maintainers can update the changelog file directly.

@hannahblair
Copy link
Collaborator Author

Idk why those recordings are slow I am actually clicking faster than that

@hannahblair hannahblair marked this pull request as ready for review January 29, 2025 15:28
@abidlabs
Copy link
Member

Nice UX improvement @hannahblair! I tested this, and had a few comments:

  • I think the multiple selection should also work with the keyboard. i.e. pressing shift+right arrow to also select the next cell on the right
  • Speaking of keyboard, I'm pretty certain you could previously navigate between cells in a dataframe using the arrow keys. However, I can't do it in this PR
  • After selecting a group of cells, pressing delete has no effect for me. I was testing the matrix_transpose demo:
Screen.Recording.2025-01-29.at.12.05.09.PM.mov
  • For me the biggest QoL improvement related to this PR would be if this allowed me to cmd+c copy a range of cells. Right now, we don't support cmd+c copying even a single cell, but if we could allow this as part of this PR or a follow-up PR, that'd be huge!

@hannahblair
Copy link
Collaborator Author

hannahblair commented Feb 3, 2025

Thanks for reviewing @abidlabs!

  • cell selection with shift+arrow keys now works
  • navigating between cells using the arrow keys (and checking the text boundaries so as to avoid preventing a clash with the logic to edit text) is quite complicated so I'd prefer to do this in a separate PR so I can isolate the testing for it
  • the delete is now fixed - I was actually I actually added logic for backspace instead of the delete button but now I've updated it to apply to both keys
  • you can now select cells and cmd+c those values to copy them :)

Copy link
Member

@abidlabs abidlabs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Beautiful! Works great @hannahblair

@hannahblair hannahblair merged commit 8e40c15 into main Feb 3, 2025
24 checks passed
@hannahblair hannahblair deleted the group-cell-selection branch February 3, 2025 21:42
@Hellwz
Copy link

Hellwz commented Feb 6, 2025

Appreciate for the great work! With this new feature, I'm wondering if I can get which cells are currently selected by the user in Python? For example, implement such a function: the user selects some cells, clicks a button, and the values of these selected cells are increased by 1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

multi select cells + clearing
4 participants