gutenberg icon indicating copy to clipboard operation
gutenberg copied to clipboard

Safari – pasting text into title doesn't work as expected

Open marekzelezny opened this issue 1 year ago • 5 comments

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

  1. Open edit screen for any post
  2. Use CMD+V to paste a text into title (like: 'test' between Hello and World)
  3. 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

marekzelezny avatar May 29 '23 09:05 marekzelezny

I've noticed this as well; even with selecting all/pasting a whole new title in.

richtabor avatar Jun 01 '23 03:06 richtabor

Got the same on the post/page Title

Image

murshed avatar Jun 22 '23 04:06 murshed

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

megane9988 avatar Jul 07 '23 07:07 megane9988

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)

lukasbesch avatar Jul 10 '23 14:07 lukasbesch

It’s not only pasting, also copying doesn’t work as expected.

  1. Write "This is a test" as title
  2. Mark the word "test" by double-clicking on it
  3. Press ⌘ + C to copy it
  4. 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.

MatzeKitt avatar Aug 08 '23 05:08 MatzeKitt

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 :(

Kuuuzya avatar Apr 08 '24 10:04 Kuuuzya

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

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

title-test-65

6.4

title-test-64

6.3

title-test-63

6.2

title-test-62

6.1

title-test-61

ironprogrammer avatar Apr 18 '24 20:04 ironprogrammer

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

CleanShot 2024-08-21 at 06 49 52

Mamaduka avatar Aug 21 '24 02:08 Mamaduka

Here's the fix - #64671.

Mamaduka avatar Aug 21 '24 06:08 Mamaduka