-
Notifications
You must be signed in to change notification settings - Fork 122
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
Cursor jumps to beginning #217
Comments
u need to set new value on onblur event, not on onchage |
Wow, crazy thats the simple fix, thank you! |
but didn't worked for me but i using in react web |
thank you dear. |
it worked but when we directly navigate backword with browser's back button and our cursor is on editor |
onBlur seems to fix this problem, but it won't work well if I want to validate the form during import. Please fix it soon. |
Any update on this? Blur only options isn't really viable, especially if you need to validate the field on change. |
@bluefqcebaby thanks dude 😄 Could you please add a bit detail as in why does onBlur work not onChange? |
Thanks, bro |
Also affected by this. I want to track changes within the input so I can trigger changes in the UI (e.g. enabling the save button). Only being able to run this logic after the input blurs makes it more complicated to achieve this effect. |
I've found there's heaps of other tickets for this same issue, going back several years and no solid resolutions... people trying to create a new wrapper (to replace this entirely). Issues all stem from trying to control it as a controlled input (e.g. onChange updates a useState on every key stroke). There's no onFocus handler, making it difficult to ignore updates. The editor is great, but this library doesn't really make it react friendly... |
For anybody reading this, this bug doesn't occur if you use the component as an uncontrolled component. Meaning, use JoditEditor's function MyJoditEditor({ placeholder, defaultValue, onChange }: MyProps) {
const editor = useRef<Jodit>(null);
const defaultValueSet = useRef<boolean>(false);
useEffect(() => {
if (defaultValue && editor.current && !defaultValueSet.current) {
editor.current.setEditorValue(defaultValue);
defaultValueSet.current = true;
}
}, [defaultValue]);
return (
<JoditEditor
ref={editor}
config={{ readonly: false }}
onChange={onChange}
/>
);
} |
I fixed it this way
or u can in onChange dispatch value to store and don't use onBlur event to save it. useEffect({dispatch value from store},[]) |
I fixed some of the known issues of Jodit in this repository, including this one. |
Thank you, it's working. |
Not sure when this started happening but when typing the cursor randomly jumps to the start of the input
Deployed repro
Code
Deployed using next.js and have to use next/dynamic for ssr issues.
Seems to be when using onChange + value, the onChange callback sets a weird value
Screen.Recording.2022-12-12.at.15.42.27.mov
The text was updated successfully, but these errors were encountered: