On OnChange the editor loses focus
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 406
- Forks
- 131
- Avg merge
- 2h 32m
- Merged PRs (30d)
- 2
Description
Hi,
I need to use setContent on the event OnChange instead of on OnBlur but if I do this the editor loses the focus every time the function is called and some errors appear on the console.
Does anyone know how to solve this? Or is it mandatory to use onBlur? Thanks!
import React, { useState, useRef } from "react";
import JoditEditor from "jodit-react";
const Editor = ({ value, onChange }: IEditorProps): JSX.Element => {
const editor = useRef(null);
const [content, setContent] = useState(value);
const config = {
readonly: false,
};
const handleChange = (newContent: string) => {
setContent(newContent);
};
return (
<JoditEditor ref={editor} value={content} config={config} onChange={handleChange} />
);
};
interface IEditorProps {
value: string;
onChange: (value: string) => void;
}
export default Editor;
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the issue with the provided JoditEditor component, using the ref, controlled value, and onChange handler shown in the report. Inspect the JoditEditor focus and value-update behavior; done means setContent can run from OnChange without losing editor focus or producing console errors.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- react, typescript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100