Skip to content

Commit

Permalink
Merge pull request #393 from FormidableLabs/fix-cursor
Browse files Browse the repository at this point in the history
fix: move onchange inside event handler
  • Loading branch information
carbonrobot authored Nov 19, 2024
2 parents 0156fdb + 8b2c893 commit a988388
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions packages/react-live/src/components/Editor/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,21 @@ const CodeEditor = (props: Props) => {
setCode(props.code);
}, [props.code]);

useEditable(editorRef, (text) => setCode(text.slice(0, -1)), {
disabled: props.disabled,
indentation: tabMode === "indentation" ? 2 : undefined,
});
useEditable(
editorRef,
(text) => {
const t = text.slice(0, -1);
setCode(t);

useEffect(() => {
if (props.onChange) {
props.onChange(code);
if (props.onChange) {
props.onChange(t);
}
},
{
disabled: props.disabled,
indentation: tabMode === "indentation" ? 2 : undefined,
}
}, [code]);
);

return (
<div className={props.className} style={props.style}>
Expand Down

0 comments on commit a988388

Please sign in to comment.