Skip to content

LinkControl crashing block in Pattern Editor #65874

@StYankov

Description

@StYankov

Description

The LinkControl component from the @wordpress/block-editor package does not work as expected when used inside the Pattern Editor. The block crashes with some JS errors in the console:
Image

Here's the error with SCRIPT_DEBUG set to true
Image

Step-by-step reproduction instructions

Steps to Reproduce

  1. Create a Pattern with a block that contains a LinkControl Image

  2. Open Pattern Editor

  3. Open the Pattern with the LinkControlImage

All I know is that the error is caused by the useCopyToClipboard hook inside used by LinkPreview component internally in LinkControl.
I tried installing the Gutenberg Plugin 19.3 but it still crashes.

Screenshots, screen recording, code snippet

I created a simple test repo with WP and a theme with block that contains a LinkControl to reproduce the issue: repo block edit.js

Environment info

WordPress Version: 6.6.2
Browser: Chrome 127

Please confirm that you have searched existing issues in the repo.

  • Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

  • Yes

UPDATE:
The issue appears after WP 6.5. Before that the example block doesn't crash in the Pattern Editor.
Update:
Added a comment describing the problem and a possible solution

Metadata

Metadata

Assignees

Labels

[Feature] Link EditingLink components (LinkControl, URLInput) and integrations (RichText link formatting)[Status] In ProgressTracking issues with work in progress[Type] BugAn existing feature does not function as intended

Type

No fields configured for Bug.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions