Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The content entered by the Chinese input method is displayed repeatedly #5023

Open
Hhpon opened this issue Jun 9, 2022 · 6 comments
Open

Comments

@Hhpon
Copy link

Hhpon commented Jun 9, 2022

Description
The compositionEnd event and the beforeInput event trigger the insertText event repeatedly, resulting in repeated typing。

Recording
https://user-images.githubusercontent.com/33001067/172849978-2e272d4b-ff1a-43b7-966e-68fc9508b062.mov

Sandbox
A link to a sandbox where the error can be reproduced. (You can start from the base sandbox here: https://codesandbox.io/s/slate-reproductions-c7gyg or refer to the Slate website too.)

Steps
To reproduce the behavior:

  1. open Safari Broswer
  2. Change userAgent to "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko)"
  3. Switch Chinese input method, type anything

Expectation
I know this problem is caused by duplication of insert text with onCompositionEnd event and onBeforeInput event. Shouldn't apple webkit webview be drained in onCompositionEnd event;

                // COMPAT: In Chrome, `beforeinput` events for compositions
                // aren't correct and never fire the "insertFromComposition"
                // type that we need. So instead, insert whenever a composition
                // ends since it will already have been committed to the DOM.
                if (
                  !IS_SAFARI &&
                  !IS_FIREFOX_LEGACY &&
                  !IS_IOS &&
                  !IS_QQBROWSER &&
                  !IS_WECHATBROWSER &&
                  !IS_UC_MOBILE &&
                  event.data
                ) {
                  Editor.insertText(editor, event.data)
                }

Environment

  • Slate Version: 0.80.0
  • Operating System: macos
  • Browser: macos webview userAgent Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko)

Context
same type issue

@RyuzakiZ99
Copy link

Has this bug already been fixed? Or perhaps some sort of workaround has been found?

@manly0305
Copy link

Same issue

@Hhpon
Copy link
Author

Hhpon commented May 1, 2023

Has this bug already been fixed? Or perhaps some sort of workaround has been found?

Is your current slate operating environment the same?“macos webview userAgent Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko)”

@RyuzakiZ99
Copy link

RyuzakiZ99 commented Aug 14, 2023

@Hhpon Yes, same environment. I'm trying to set a custom user-agent for the browser but slate doesn't seem to recognize it

useEffect(() => { let userAgent = window.navigator.userAgent console.info(userAgent) Object.defineProperty(navigator, 'userAgent', { get: function () { return 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.2 Safari/605.1.15' } }) userAgent = window.navigator.userAgent console.info(userAgent) }, [])

Is there a way to set it so that Slate picks up? The code above seems to log the new user-agent correctly, but is still doesn't work.

@Hhpon
Copy link
Author

Hhpon commented Aug 15, 2023

@Hhpon Yes, same environment. I'm trying to set a custom user-agent for the browser but slate doesn't seem to recognize it

useEffect(() => { let userAgent = window.navigator.userAgent console.info(userAgent) Object.defineProperty(navigator, 'userAgent', { get: function () { return 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.2 Safari/605.1.15' } }) userAgent = window.navigator.userAgent console.info(userAgent) }, [])

Is there a way to set it so that Slate picks up? The code above seems to log the new user-agent correctly, but is still doesn't work.

hello,Is your slate running in a macos webview? My solution at the time was uesrAgent modified by the developer of webview.

@RyuzakiZ99
Copy link

I'll try to change the webview, thank you!
Also noticed that the bug also happens with a browser with user-agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) MobileSafari/18614.3.7.1.5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants