gutenberg
gutenberg copied to clipboard
Safari – pasting text into title doesn't work as expected
Description
When pasting a text into title, the copied text is pasted in combination with a copy of title at the end of title. This happens only in Safari while using CMD+V. Using paste from menubar works fine.
Step-by-step reproduction instructions
- Open edit screen for any post
- Use CMD+V to paste a text into title (like: 'test' between Hello and World)
- Result is: Hello world!testHello world!
Screenshots, screen recording, code snippet
https://github.com/WordPress/gutenberg/assets/6258792/bb07ab19-3b4e-4707-b1cb-c10bddac9d10
Environment info
- WordPress 6.2.2, Twenty Twenty-Three (clean install)
- No active plugins
- Safari 16.4
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
I've noticed this as well; even with selecting all/pasting a whole new title in.
Got the same on the post/page Title
I got same.
- macOS 13.0(22A8380)
- Safari 16.1 (18614.2.9.1.12)
https://github.com/WordPress/gutenberg/assets/1205958/b519997b-3232-4a6b-8250-c1bf2583dc78
I noticed the same issue. Additional information:
The cursor position before the paste does not matter, the result is always the same as described above. After pasting, the cursor position is at the beginning (before the first letter).
My testing environment:
- macOS 12.6.5 (21G531)
- Safari 16.5 (17615.2.9.11.6, 17615)
It’s not only pasting, also copying doesn’t work as expected.
- Write "This is a test" as title
- Mark the word "test" by double-clicking on it
- Press ⌘ + C to copy it
- Paste the clipboard content with ⌘ + V inside the editor’s content (or anything else)
Expected: the word "test" is pasted.
Current behavior: The whole title "This is a test" is pasted.
You can also see via clipboard manager that the whole title is inside the clipboard manager instead of just the one word.
Hi everyone. Sorry, didn't noticed this ticket. If there any updates or fixes? Maybe someone know, how to fix it in Safari, cause using other browser on Mac is not to convenient :(
Today I dug a little deeper into this behavior, and it appears to affect WP back to 6.1. Not to say it's been an issue since the 6.1 release, but does affect the handling of ⌘+V since reported with Safari 16.4.
Reproduction Report
Environment
- Hardware: MacBook Pro Apple M1 Pro
- OS: macOS 14.4.1
- Browser: Safari 17.4.1, Google Chrome 123.0.6312.124, Mozilla Firefox 124.0.2
- PHP: 8.2.18
- MySQL: 8.0.27
- WordPress: 6.6-alpha-57778-src, 6.5.2, 6.0.2
Actual Results
- Reproduction in Safari with:
- ✅
wordpress-develop:trunk
Playground and local install - ✅ 6.5 - Playground and local install
- ✅ 6.5 - Playground with Gutenberg
- ✅ 6.4 - Playground
- ✅ 6.3 - Playground
- ✅ 6.2 - Playground
- ✅ 6.1 - Playground
- ❌ 6.0 local install
- ✅
Additional Notes
- It's notable that after pasting with ⌘+V in Safari, the carat is positioned at the start of the title. This is unexpected behavior for pasting operations, where the carat should be at the end of the pasted text.
- Could not reproduce in Chrome or Firefox.
Supplemental Artifacts
Here are animated GIFs for tested versions:
6.5
6.4
6.3
6.2
6.1
When pasting in the Safari post title, I noticed that the RichText value's start
and end
properties are undefined
. This is the reason for unexpected paste behavior. Emulating the same in Chrome will give us the same results:
It can be run via the DevTools console in the editor
const value = { ...wp.richText.create( { html: 'Hey' } ), start: undefined, end: undefined };
const newValue = wp.richText.insert( value, wp.richText.create( { html: ' There' } ) );
// { text: 'Hey ThereHey' }
console.log( newValue );
Screenshot
Here's the fix - #64671.