Skip to content

Commit

Permalink
Fix: Linked featured image block cannot be selected correctly (WordPr…
Browse files Browse the repository at this point in the history
…ess#68775)

Co-authored-by: t-hamano <[email protected]>
Co-authored-by: carolinan <[email protected]>
  • Loading branch information
3 people authored Jan 21, 2025
1 parent 39ed61d commit e68767f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 17 deletions.
17 changes: 2 additions & 15 deletions packages/block-library/src/post-featured-image/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,6 @@ function getMediaSourceUrlBySizeSlug( media, slug ) {
);
}

const disabledClickProps = {
onClick: ( event ) => event.preventDefault(),
'aria-disabled': true,
};

export default function PostFeaturedImageEdit( {
clientId,
attributes,
Expand Down Expand Up @@ -318,11 +313,7 @@ export default function PostFeaturedImageEdit( {
{ controls }
<div { ...blockProps }>
{ !! isLink ? (
<a
href={ postPermalink }
target={ linkTarget }
{ ...disabledClickProps }
>
<a href={ postPermalink } target={ linkTarget }>
{ placeholder() }
</a>
) : (
Expand Down Expand Up @@ -430,11 +421,7 @@ export default function PostFeaturedImageEdit( {
<figure { ...blockProps }>
{ /* If the featured image is linked, wrap in an <a /> tag to trigger any inherited link element styles */ }
{ !! isLink ? (
<a
href={ postPermalink }
target={ linkTarget }
{ ...disabledClickProps }
>
<a href={ postPermalink } target={ linkTarget }>
{ image }
</a>
) : (
Expand Down
4 changes: 2 additions & 2 deletions packages/block-library/src/post-featured-image/editor.scss
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,9 @@

// When the Post Featured Image block is linked,
// it's wrapped with a disabled <a /> tag.
// Restore cursor style so it doesn't appear 'clickable'.
// Ensure that the link is not clickable.
> a {
cursor: default;
pointer-events: none;
}

// When the Post Featured Image block is linked,
Expand Down

0 comments on commit e68767f

Please sign in to comment.