Skip to content

Commit

Permalink
Add check for lightbox values during image block migration (#56057)
Browse files Browse the repository at this point in the history
  • Loading branch information
artemiomorales committed Nov 13, 2023
1 parent 8ecddc9 commit 901dc7d
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions packages/block-library/src/image/deprecated.js
Original file line number Diff line number Diff line change
Expand Up @@ -1047,6 +1047,14 @@ const v8 = {
},
},
migrate( { width, height, ...attributes } ) {
// We need to perform a check here because in cases
// where attributes are added dynamically to blocks,
// block invalidation overrides the isEligible() method
// and forces the migration to run, so it's not guaranteed
// that `behaviors` or `behaviors.lightbox` will be defined.
if ( ! attributes.behaviors?.lightbox ) {
return attributes;
}
const {
behaviors: {
lightbox: { enabled },
Expand Down

0 comments on commit 901dc7d

Please sign in to comment.