Skip to content

Commit

Permalink
Gallery refactor - Infer version from existing content (#32270)
Browse files Browse the repository at this point in the history
* Give content precedence over flag in edit wrapper

This modifies the logic in the gallery edit wrapper function to infer
version information from existing content when the editor encounters
content created from the new implementation and the flag is not set.
  • Loading branch information
mkevins authored May 30, 2021
1 parent b976235 commit 1a4345a
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions packages/block-library/src/gallery/edit-wrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,15 @@ export default function GalleryEditWrapper( props ) {
return settings.__experimentalGalleryRefactor;
}, [] );

// This logic is used to infer version information from content with higher
// precedence than the flag. New galleries (and existing empty galleries) will
// honor the flag.
const hasNewVersionContent = !! attributes?.imageCount;
const hasOldVersionContent =
0 < attributes?.ids?.length || 0 < attributes?.images?.length;
if (
! __experimentalGalleryRefactor ||
attributes?.ids?.length > 0 ||
attributes?.images?.length > 0
hasOldVersionContent ||
( ! hasNewVersionContent && ! __experimentalGalleryRefactor )
) {
return <GalleryEditV1 { ...props } />;
}
Expand Down

0 comments on commit 1a4345a

Please sign in to comment.