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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix gallery select event with custom height and allow_preview=False #4551

Merged
merged 3 commits into from Jun 17, 2023

Conversation

freddyaboulton
Copy link
Collaborator

Description

Closes: #4543

When setting a height on the gallery, the select event is not being triggered when allow_preview=False because can_zoom is being calculated as False.

Not too familiar with the gallery code but I assumed the can_zoom logic is correct. Since the gallery won't zoom with allow_preview=False, my fix is to set can_zoom=true in that case to trigger the event. But please check me @pngwn @hannahblair @aliabid94 @dawoodkhan82

Checklist:

  • I have performed a self-review of my own code
  • I have added a short summary of my change to the CHANGELOG.md
  • My code follows the style guidelines of this project
  • I have commented my code in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

A note about the CHANGELOG

Hello 馃憢 and thank you for contributing to Gradio!

All pull requests must update the change log located in CHANGELOG.md, unless the pull request is labeled with the "no-changelog-update" label.

Please add a brief summary of the change to the Upcoming Release > Full Changelog section of the CHANGELOG.md file and include
a link to the PR (formatted in markdown) and a link to your github profile (if you like). For example, "* Added a cool new feature by [@myusername](link-to-your-github-profile) in [PR 11111](https://github.com/gradio-app/gradio/pull/11111)".

If you would like to elaborate on your change further, feel free to include a longer explanation in the other sections.
If you would like an image/gif/video showcasing your feature, it may be best to edit the CHANGELOG file using the
GitHub web UI since that lets you upload files directly via drag-and-drop.

@gradio-pr-bot
Copy link
Contributor

All the demos for this PR have been deployed at https://huggingface.co/spaces/gradio-pr-deploys/pr-4551-all-demos

@freddyaboulton freddyaboulton force-pushed the 4543-height-with-allow-preview-false-bug branch from 148fa84 to 9b68363 Compare June 16, 2023 15:49
@freddyaboulton freddyaboulton marked this pull request as ready for review June 16, 2023 15:58
Copy link
Member

@pngwn pngwn left a comment

Choose a reason for hiding this comment

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

Hmm. Interesting. When allow_preview=False technically it isn't possible to 'select' an image (going by the semantics of 'selected' in this component). You are just clicking it, but maybe that distinction isn't important. I do think we should probably refactor this code to handle selection + full size previewing separately to avoid confusion. And also because i think we should implement multi-select for the gallery too at some point (and you obviously can't preview multiple fullsize images at once).

If we're happy with the select semantics in this PR them I'm happy for it to be merged (code looks fine).

cc @abidlabs @aliabd @dawoodkhan82 @hannahblair

@abidlabs
Copy link
Member

abidlabs commented Jun 17, 2023

The semantics are good for me. We use .select() in other components to mean that you've selected on some portion of the value as opposed to clicking on the entire thing, and we provide the event data to go along with that. E.g. in gr.Image clicking on a particular pixel triggers the .select() event handler even though there is no change in the UI. So in this case, I think .select() still works.

@pngwn
Copy link
Member

pngwn commented Jun 17, 2023

Sounds good. Happy to merge then!

@abidlabs
Copy link
Member

Sounds good let鈥檚 merge it in

@abidlabs abidlabs merged commit 98d1e8d into main Jun 17, 2023
8 checks passed
@abidlabs abidlabs deleted the 4543-height-with-allow-preview-false-bug branch June 17, 2023 19:11
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.

allow_preview=False doesn't seem to work properly
4 participants