Skip to content

Commit

Permalink
#3495 fix dispatch selectTool rerender issue
Browse files Browse the repository at this point in the history
  • Loading branch information
StarlaStarla committed Nov 23, 2023
1 parent 698fe7e commit 6b894d7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
7 changes: 3 additions & 4 deletions packages/ketcher-polymer-editor-react/src/Editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@ function Editor({ theme, togglerComponent }: EditorProps) {
const canvasRef = useRef<SVGSVGElement>(null);
const errorTooltipText = useAppSelector(selectErrorTooltipText);
const editor = useAppSelector(selectEditor);
const activeTool = useAppSelector(selectEditorActiveTool);
let keyboardEventListener;
const [isMonomerLibraryHidden, setIsMonomerLibraryHidden] = useState(false);

Expand Down Expand Up @@ -194,10 +193,10 @@ function Editor({ theme, togglerComponent }: EditorProps) {
debouncedShowPreview({ monomer, style: previewStyle });
}, []);

const handleClosePreview = () => {
const handleClosePreview = useCallback(() => {
debouncedShowPreview.cancel();
dispatch(showPreview(undefined));
};
}, []);

useEffect(() => {
editor?.events.mouseOverMonomer.add((e) => {
Expand All @@ -210,7 +209,7 @@ function Editor({ theme, togglerComponent }: EditorProps) {
handleClosePreview();
handleOpenPreview(e);
});
}, [editor, activeTool]);
}, [editor, handleOpenPreview, handleClosePreview]);

useEffect(() => {
editor?.zoomTool.observeCanvasResize();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,7 @@ const MonomerGroup = ({
};

const selectMonomer = (monomer: MonomerItemType) => {
// why would this re-render rnabuilder?
// dispatch(selectTool('monomer'));
dispatch(selectTool('monomer'));
setSelectedItemInGroup(monomer);

if (['FAVORITES', 'PEPTIDE', 'CHEM'].includes(libraryName ?? '')) {
Expand Down

0 comments on commit 6b894d7

Please sign in to comment.