Skip to content

RichText: fix paste handler crash when pasting files - #81010

Merged
jsnajdr merged 1 commit into
trunkfrom
fix/paste-files-crash
Jul 31, 2026
Merged

RichText: fix paste handler crash when pasting files#81010
jsnajdr merged 1 commit into
trunkfrom
fix/paste-files-crash

Conversation

@jsnajdr

@jsnajdr jsnajdr commented Jul 31, 2026

Copy link
Copy Markdown
Member

Fixes a crash in RichText paste handler when files are pasted.

Steps to reproduce:

  1. Create a core/pullquote block and focus the value rich text field
  2. Try to paste a file into the field. For example, "Copy" a file in Finder, and in the focused field, select "Paste" from the right-click context menu.

The Pullquote block cannot accept a file paste: the value field can only accept a text, and unlike Paragraph or Heading, it doesn't support splitting. The useWritingFlow/useClipboardHandler doesn't do the paste, and the event falls through to the RichText default handler, which crashes because there is no text (plainText/html) in the event.

Screenshot 2026-07-31 at 10 28 10

This PR fixes the crash by adding a guard.

@jsnajdr
jsnajdr requested review from Mamaduka, aduth and ellatrix July 31, 2026 08:38
@jsnajdr jsnajdr self-assigned this Jul 31, 2026
@jsnajdr jsnajdr added [Type] Bug An existing feature does not function as intended [Package] Block editor /packages/block-editor labels Jul 31, 2026
@github-actions

Copy link
Copy Markdown

Size Change: 0 B

Total Size: 7.76 MB

compressed-size-action

@Mamaduka Mamaduka left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, @jsnajdr!

@github-actions

Copy link
Copy Markdown

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: jsnajdr <jsnajdr@git.wordpress.org>
Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@jsnajdr
jsnajdr force-pushed the fix/paste-files-crash branch from d12c10f to b1cdde7 Compare July 31, 2026 08:50
@jsnajdr jsnajdr added this to the Gutenberg 23.7 milestone Jul 31, 2026
@jsnajdr
jsnajdr merged commit 0575c44 into trunk Jul 31, 2026
43 checks passed
@jsnajdr
jsnajdr deleted the fix/paste-files-crash branch July 31, 2026 09:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Package] Block editor /packages/block-editor [Type] Bug An existing feature does not function as intended

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants