Fix a bug that trailing content disappears when using IME in Safari #185

Closed
usualoma wants to merge 1 commit from fix-safari-ime-trailing-content into master
usualoma commented 2025-09-05 01:55:06 +02:00 (Migrated from github.com)

This is similar to #184, but occurs in a slightly different situation.

While working with ProseMirror inside a shadow DOM, I encountered an issue in Safari when using an IME environment. This pull request provides a fix for that problem.

Steps to reproduce

  1. Apply ProseMirror inside a shadow DOM
  2. Move the cursor after the last img element
  3. Enable IME
  4. Enter text
  5. Press Enter to confirm

Expected result

  • The content entered in step 4 remains.

Actual result

  • The content entered in step 4 disappears.

https://github.com/user-attachments/assets/561d160e-67c4-4522-bdd4-78cbaf749d8b

Conditions for occurrence

  • This does not occur when Shadow DOM is not used.
  • Does not occur in browsers other than Safari

Patch contents

When using an IME within a shadow DOM in Safari, calling flush() to insert content after the last img element causes content visible during input to disappear upon confirmation. Therefore, I changed it to call flushSoon(). I don't fully understand the situation with IE-specific code, but I suspect a similar issue occurs.

This change also affects cases not using shadow DOM, but flushSoon() should still be sufficient in those scenarios.

This is similar to #184, but occurs in a slightly different situation. While working with ProseMirror inside a shadow DOM, I encountered an issue in Safari when using an IME environment. This pull request provides a fix for that problem. ### Steps to reproduce 1. Apply ProseMirror inside a shadow DOM * [example](https://github.com/usualoma/prosemirror-example/tree/main/shadow-ime-append-text) 2. Move the cursor after the last img element 3. Enable IME 4. Enter text 5. Press Enter to confirm ### Expected result * The content entered in step 4 remains. ### Actual result * The content entered in step 4 disappears. https://github.com/user-attachments/assets/561d160e-67c4-4522-bdd4-78cbaf749d8b ### Conditions for occurrence * This does not occur when Shadow DOM is not used. * Does not occur in browsers other than Safari ### Patch contents When using an IME within a shadow DOM in Safari, calling `flush()` to insert content after the last `img` element causes content visible during input to disappear upon confirmation. Therefore, I changed it to call `flushSoon()`. I don't fully understand the situation with IE-specific code, but I suspect a similar issue occurs. This change also affects cases not using shadow DOM, but `flushSoon()` should still be sufficient in those scenarios.
marijnh commented 2025-09-05 15:17:43 +02:00 (Migrated from github.com)

Patch 5daf445cb1 solves this in a less invasive way.

Patch 5daf445cb1c1d6 solves this in a less invasive way.
usualoma commented 2025-09-05 22:43:36 +02:00 (Migrated from github.com)

Thank you very much for resolving this issue.
I have confirmed that the fix by 5daf445 also works in my environment.

Thank you very much for resolving this issue. I have confirmed that the fix by 5daf445 also works in my environment.
marijnh commented 2025-09-06 11:14:35 +02:00 (Migrated from github.com)

Thanks for confirming. I've tagged a 1.41.0

Thanks for confirming. I've tagged a 1.41.0

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
prosemirror/prosemirror-view!185
No description provided.