Skip to content

Commit

Permalink
Handle edge case of removing existing link when lightbox is fully ena…
Browse files Browse the repository at this point in the history
…bled
  • Loading branch information
artemiomorales committed Mar 21, 2024
1 parent 248ca14 commit d34444c
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions packages/block-library/src/image/image.js
Original file line number Diff line number Diff line change
Expand Up @@ -268,14 +268,25 @@ export default function Image( {
lightbox: { enabled: false },
} );
} else {
resetLightbox();
setAttributes( {
lightbox: undefined,
} );
}
}

function resetLightbox() {
setAttributes( {
lightbox: undefined,
} );
// When deleting a link from an image while lightbox settings
// are enabled by default, we should disable the lightbox,
// otherwise the resulting UX looks like a mistake.
if ( lightboxSetting?.enabled && lightboxSetting?.allowEditing ) {
setAttributes( {
lightbox: { enabled: false },
} );
} else {
setAttributes( {
lightbox: undefined,
} );
}
}

function onSetTitle( value ) {
Expand Down

0 comments on commit d34444c

Please sign in to comment.