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

Tiled gallery block: limit the columns count to the images count #30582

Merged
merged 1 commit into from
Feb 6, 2019

Conversation

simison
Copy link
Member

@simison simison commented Feb 4, 2019

Update the columns attribute when the onSelectImages function fires so that if images are removed via the media modal, the columns will be updated. This way columns won't be higher than the new number of images.

Previously this worked if removing images via the X in the editor, but not if you removed them via the media modal.

Kudos for @brentswisher as this is basically their fix from upstream core gallery block: WordPress/gutenberg#13488

Fixes #30015

Changes proposed in this Pull Request

  • Limit number of columns when removing images. Won't let the number of columns stay higher than the number of images.

Testing instructions

  • Create a Jetpack site and Set up Jetpack: gutenpack-jn
  • Add a tiled gallery block with multiple images,
  • set the columns to be the maximum allowed.
  • Edit the gallery via the media modal and remove images.
  • When you save the media modal, the columns should be adjusted to match the new number of photos.

@simison simison added [Type] Bug [Goal] Gutenberg Working towards full integration with Gutenberg [Block] Tiled Gallery labels Feb 4, 2019
@matticbot
Copy link
Contributor

@simison simison requested a review from sirreal February 4, 2019 20:26
max={ Math.min( MAX_COLUMNS, images.length ) }
/>
) }
{ layoutSupportsColumns( layoutStyle ) && images.length > 1 && (
Copy link
Member Author

Choose a reason for hiding this comment

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

Unrelated Prettier changes.

Copy link
Member

@sirreal sirreal left a comment

Choose a reason for hiding this comment

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

👍

@sirreal sirreal added [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. [Status] Ready to Merge labels Feb 5, 2019
@simison simison merged commit 8ed3aaa into master Feb 6, 2019
@simison simison deleted the fix/tiled-gallery-columns-on-select-images branch February 6, 2019 07:52
@matticbot matticbot removed [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. [Status] Ready to Merge labels Feb 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Tiled Gallery [Goal] Gutenberg Working towards full integration with Gutenberg [Type] Bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Tiled Gallery: Adjust columns attribute when images are removed
3 participants