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

When typing Chinese,the placeholder dosen't immediately disappear #4306

Closed
YaoKaiLun opened this issue Jun 1, 2021 · 2 comments
Closed
Labels

Comments

@YaoKaiLun
Copy link
Contributor

Description
When I typing Chinese,the placeholder dosen't immediately disappear.

Recording
image

Sandbox
https://www.slatejs.org/examples/custom-placeholder

@YaoKaiLun YaoKaiLun added the bug label Jun 1, 2021
@YaoKaiLun
Copy link
Contributor Author

YaoKaiLun commented Jun 1, 2021

My current solution like below:

const [isTyping, setIsTyping] = useState(false);
const handleMouseDown = useCallback(event => {
    if (event.keyCode === 229) {
      setIsTyping(true);
    }
    ...
}, []);
const handleContentChange = (...props) => {
    setIsTyping(false);
    ...
}

<Slate editor={editor} value={content} onChange={handleContentChange}>
      <Editable
        ...
        onKeyDown={handleMouseDown}
        placeholder={isTyping ? '' : 'Type something'}
      />
 </Slate>

@YaoKaiLun
Copy link
Contributor Author

Finnally, I use this:

<Editable
     placeholder={isComposing ? '' : 'Type something'}
     onCompositionStart={() => setIsComposing(true)}
     onCompositionEnd={() => setIsComposing(false)}
/>

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

No branches or pull requests

1 participant