From 61d6b02c79149b75fe5861b62d278f75599889e6 Mon Sep 17 00:00:00 2001 From: Oliver Eyton-Williams Date: Wed, 13 Oct 2021 11:40:28 +0200 Subject: [PATCH] fix: update jaws on resize (#43777) * fix: update jaws on resize Use isProjectStep to determine if the jaws need to be updated * refactor: isProjectStep -> hasEditableRegion isProjectStep was misleading. hasEditableRegion correctly describes that function and leaves isProjectStep to enable features that are unique to project steps, but nothing to do with the editable region --- client/src/templates/Challenges/classic/editor.tsx | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/client/src/templates/Challenges/classic/editor.tsx b/client/src/templates/Challenges/classic/editor.tsx index 2883359f6e..8018439524 100644 --- a/client/src/templates/Challenges/classic/editor.tsx +++ b/client/src/templates/Challenges/classic/editor.tsx @@ -293,7 +293,7 @@ const Editor = (props: EditorProps): JSX.Element => { editorRef.current = editor; data.editor = editor; - if (isProjectStep()) { + if (hasEditableRegion()) { initializeProjectStepFeatures(); addContentChangeListener(); showEditableRegion(editor); @@ -658,7 +658,7 @@ const Editor = (props: EditorProps): JSX.Element => { // Currently, only practice project parts have editable region markers // This function is used to enable multiple editor tabs, jaws, etc. - function isProjectStep() { + function hasEditableRegion() { const editableRegionBoundaries = getEditableRegionFromRedux(); return editableRegionBoundaries.length === 2; } @@ -961,15 +961,15 @@ const Editor = (props: EditorProps): JSX.Element => { const { editor } = data; const hasChangedContents = updateEditorValues(); - if (hasChangedContents && isProjectStep()) { + if (hasChangedContents && hasEditableRegion()) { initializeProjectStepFeatures(); updateDescriptionZone(); updateOutputZone(); } - if (hasChangedContents && !isProjectStep()) editor?.focus(); + if (hasChangedContents && !hasEditableRegion()) editor?.focus(); - if (isProjectStep() && editor) { + if (hasEditableRegion() && editor) { if (hasChangedContents) { editor.focus(); showEditableRegion(editor); @@ -1078,7 +1078,7 @@ const Editor = (props: EditorProps): JSX.Element => { useEffect(() => { const editor = data.editor; editor?.layout(); - if (data.startEditDecId) { + if (hasEditableRegion()) { updateDescriptionZone(); updateOutputZone(); }