Skip to content

Commit

Permalink
fix: Select Gallery block when adding media (#53127)
Browse files Browse the repository at this point in the history
* fix: Select Gallery block on focus

Update the Gallery block to mirror the behaviour of other blocks, e.g.
the Image block. As a specific example, tapping "Add media" within an
empty Gallery block now results in the Gallery block becoming the
actively selected block.

* docs: Add change log entry
  • Loading branch information
dcalhoun authored Jul 31, 2023
1 parent 5f30ade commit 66d0606
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
2 changes: 2 additions & 0 deletions packages/block-library/src/gallery/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ function GalleryEdit( props ) {
isSelected,
insertBlocksAfter,
isContentLocked,
onFocus,
} = props;

const { columns, imageCrop, linkTarget, linkTo, sizeSlug, caption } =
Expand Down Expand Up @@ -498,6 +499,7 @@ function GalleryEdit( props ) {
value: hasImageIds ? images : {},
autoOpenMediaUpload:
! hasImages && isSelected && wasBlockJustInserted,
onFocus,
},
} );
const mediaPlaceholder = (
Expand Down
4 changes: 1 addition & 3 deletions packages/block-library/src/gallery/test/index.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,7 @@ describe( 'Gallery block', () => {
/* eslint-enable jest/no-conditional-expect */
} );

// This case is disabled until the issue (https://github.com/WordPress/gutenberg/issues/38444)
// is addressed.
it.skip( 'block remains selected after dismissing the media options picker', async () => {
it( 'block remains selected after dismissing the media options picker', async () => {
// Initialize with an empty gallery
const { getByLabelText, getByText, getByTestId } =
await initializeEditor( {
Expand Down
1 change: 1 addition & 0 deletions packages/react-native-editor/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ For each user feature we should also add a importance categorization label to i
- [*] Remove Gallery caption button on mobile [#53010]
- [**] Upgrade React Native to 0.71.11 [#51303]
- [*] Upgrade Gradle to 8.2.1 & AGP to 8.1.0 [#52872]
- [*] Fix Gallery block selection when adding media [#53127]

## 1.100.1
- [**] Add WP hook for registering non-core blocks [#52791]
Expand Down

0 comments on commit 66d0606

Please sign in to comment.