Skip to content
Snippets Groups Projects
Commit 3973769c authored by chris's avatar chris
Browse files

fix editor rerender

parent c1085047
No related branches found
No related tags found
No related merge requests found
...@@ -70,7 +70,7 @@ const Editors = () => { ...@@ -70,7 +70,7 @@ const Editors = () => {
case 'ncbi': case 'ncbi':
return <NCBI />; return <NCBI />;
default: default:
return <HHMI />; return <Editoria />;
} }
}; };
......
...@@ -161,7 +161,7 @@ const WaxView = forwardRef((props, ref) => { ...@@ -161,7 +161,7 @@ const WaxView = forwardRef((props, ref) => {
const editor = ( const editor = (
<EditorContainer> <EditorContainer>
<div ref={setEditorRef} /> <div ref={setEditorRef} />
{context.activeViewId === 'main' && <WaxOverlays group="main" />} <WaxOverlays activeViewId="main" group="main" />
<WaxPortals /> <WaxPortals />
</EditorContainer> </EditorContainer>
); );
...@@ -171,7 +171,7 @@ const WaxView = forwardRef((props, ref) => { ...@@ -171,7 +171,7 @@ const WaxView = forwardRef((props, ref) => {
props.children({ props.children({
editor, editor,
}), }),
[readonly, customValues, context.activeViewId], [readonly, customValues],
); );
}); });
......
...@@ -196,7 +196,7 @@ export default ({ node, view }) => { ...@@ -196,7 +196,7 @@ export default ({ node, view }) => {
return ( return (
<NoteContainer> <NoteContainer>
{NoteEditorContainerComponent} {NoteEditorContainerComponent}
{activeViewId === noteId && <WaxOverlays group="notes" />} <WaxOverlays activeViewId={noteId} group="notes" />
</NoteContainer> </NoteContainer>
); );
}; };
/* eslint-disable react/jsx-props-no-spreading */ /* eslint-disable react/jsx-props-no-spreading */
import React, { useMemo } from 'react'; import React, { useMemo, useContext } from 'react';
import { WaxContext } from 'wax-prosemirror-core';
import { Overlay } from 'wax-prosemirror-components'; import { Overlay } from 'wax-prosemirror-components';
import usePosition from './usePosition'; import usePosition from './usePosition';
export default (Component, markType) => props => { export default (Component, markType) => props => {
const context = useContext(WaxContext);
const [position, setPosition, mark] = usePosition(markType); const [position, setPosition, mark] = usePosition(markType);
const component = useMemo( const component = useMemo(
() => ( () => (
...@@ -14,9 +17,13 @@ export default (Component, markType) => props => { ...@@ -14,9 +17,13 @@ export default (Component, markType) => props => {
{...props} {...props}
/> />
), ),
[JSON.stringify(mark), position], [JSON.stringify(mark), position, context.activeViewId],
); );
const visible = !!position.left; const visible = !!position.left;
return <Overlay position={position}>{visible && component}</Overlay>; return (
<Overlay position={position}>
{props.activeViewId === context.activeViewId && visible && component}
</Overlay>
);
}; };
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment