Skip to content

Commit

Permalink
Fix editorRefs
Browse files Browse the repository at this point in the history
  • Loading branch information
aaron7 committed Jun 10, 2024
1 parent 427b834 commit 12ca60b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions app/src/components/MarkdownEditor/Editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import './Editor.css';

type EditorProps = {
onChange: (value: string, viewUpdate: ViewUpdate) => void;
ref: React.RefObject<ReactCodeMirrorRef>;
refs: React.RefObject<ReactCodeMirrorRef>;
value: string;
webrtcProvider: WebrtcProvider;
};
Expand All @@ -33,7 +33,7 @@ const baseTheme = EditorView.baseTheme({
},
});

const Editor = ({ onChange, ref, value, webrtcProvider }: EditorProps) => {
const Editor = ({ onChange, refs, value, webrtcProvider }: EditorProps) => {
const collabPlugin = useMemo(
() => createCollabPlugin({ webrtcProvider }),
[webrtcProvider],
Expand Down Expand Up @@ -63,7 +63,7 @@ const Editor = ({ onChange, ref, value, webrtcProvider }: EditorProps) => {
]}
height="100%"
onChange={onChange}
ref={ref}
ref={refs}
theme="none"
value={value}
/>
Expand Down
6 changes: 3 additions & 3 deletions app/src/routes/Session.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const Session = () => {
const [peers, setPeers] = useState<string[]>([]);
const [value, setValue] = useState<string>('');

const editorRef = React.useRef<ReactCodeMirrorRef>({});
const editorRefs = React.useRef<ReactCodeMirrorRef>({});

// Always setup a new webrtcProvider when the session changes
useEffect(() => {
Expand Down Expand Up @@ -168,7 +168,7 @@ const Session = () => {
e: React.MouseEvent<HTMLDivElement>,
) => {
if (e.target === e.currentTarget) {
editorRef?.current?.view?.focus();
editorRefs?.current?.view?.focus();
}
};

Expand All @@ -188,7 +188,7 @@ const Session = () => {
>
<Editor
onChange={onEditorChange}
ref={editorRef}
refs={editorRefs}
value={value}
webrtcProvider={webrtcProvider}
/>
Expand Down

0 comments on commit 12ca60b

Please sign in to comment.