tiptap icon indicating copy to clipboard operation
tiptap copied to clipboard

Fix losing text selection/focus briefly when using the `focus` command on Android

Open hellovietduc opened this issue 2 years ago • 4 comments

The issue

When using the focus command in a toolbar/menubar element to toggle formatting of the selected text, the editor briefly loses focus then gains it back. This happens only on Android devices and it makes the virtual keyboard flashes (it closes down then shows up again quickly, sometimes not even showing up).

Screen recording

https://github.com/ueberdosis/tiptap/assets/33684291/9b94d45e-495a-4c24-94f8-2407608bd394

This issue is reported here but no one has solved it for Android.

Please describe your changes

I just modified the focus command's code to remove the isiOS check so (view.dom as HTMLElement).focus() is always executed.

How did you accomplish your changes

When reading the reported issue, I found a commit that at the time (2021) might resolve the issue for iOS, but right now it breaks on Android. I simply tried removing the isiOS check and it works on both platforms.

How have you tested your changes

I'm using Tiptap 2.0.6 with Vue. I modified the source code in the node_modules folder to remove the isiOS check. My test devices are:

  • Samsung Galaxy A51 (Android 12, Chrome 116)
  • Samsung Galaxy Tab S6 Lite (Android 13, Chrome 116)
  • iPhone 14 Pro (iOS 17)

I can verify that the issue is fixed and it doesn't cause any issues on iOS either.

How can we verify your changes

The issue can be reproduced by visiting the default example on Tiptap website. I don't know how to rebuild that website with this change but we can do that and use an Android device to check.

I'm not familiar with Tiptap's code so I'm not fully aware of the impact of this change. Please help me test and send feedback :D

Remarks

n/a

Checklist

  • [x] The changes are not breaking the editor
  • [ ] Added tests where possible
  • [x] Followed the guidelines
  • [x] Fixed linting issues

Related issues

https://github.com/ueberdosis/tiptap/issues/1806

hellovietduc avatar Sep 14 '23 11:09 hellovietduc

Deploy Preview for tiptap-embed ready!

Name Link
Latest commit 4b13cc2527de46c954ccd8001b197d4b0c9546df
Latest deploy log https://app.netlify.com/sites/tiptap-embed/deploys/667db8debe836c0008790d42
Deploy Preview https://deploy-preview-4448--tiptap-embed.netlify.app
Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

netlify[bot] avatar Sep 14 '23 11:09 netlify[bot]

Hello @bdbch @svenadlung, not sure if you guys have time to check this 😅

hellovietduc avatar Oct 04 '23 10:10 hellovietduc

Hey @hellovietduc I'll try to reproduce this tomorrow. Maybe we can find a quick fix.

bdbch avatar Oct 10 '23 02:10 bdbch

Hi @bdbch, was this issue fixed somewhere upstream? Currently I'm using the code in this PR as a focus_patch extension internally but I'd like to upgrade Tiptap if the issue is fixed.

hellovietduc avatar Jun 26 '24 22:06 hellovietduc

I think this PR is breaking command.focus() for us - see https://github.com/ueberdosis/tiptap/issues/5992#issue-2771015380

elledienne avatar Jan 06 '25 16:01 elledienne