From 73d9b4c1944e2936c34fd9e45beefc6b9ed9d9d0 Mon Sep 17 00:00:00 2001 From: Oliver Eyton-Williams Date: Wed, 24 Mar 2021 21:21:08 +0100 Subject: [PATCH] fix(client): split Editor panes correctly (#41570) * refactor: clean up MultifileEditor * fix: show correct splitters * fix: include splitter for JSX --- .../Challenges/classic/MultifileEditor.js | 66 ++++++++++++------- 1 file changed, 42 insertions(+), 24 deletions(-) diff --git a/client/src/templates/Challenges/classic/MultifileEditor.js b/client/src/templates/Challenges/classic/MultifileEditor.js index 648afcfe67..3c23acb08e 100644 --- a/client/src/templates/Challenges/classic/MultifileEditor.js +++ b/client/src/templates/Challenges/classic/MultifileEditor.js @@ -169,7 +169,7 @@ class MultifileEditor extends Component { editorRef, theme, resizeProps, - visibleEditors + visibleEditors: { indexcss, indexhtml, indexjs, indexjsx } } = this.props; const editorTheme = theme === 'night' ? 'vs-dark-custom' : 'vs-custom'; // TODO: the tabs mess up the rendering (scroll doesn't work properly and @@ -185,11 +185,22 @@ class MultifileEditor extends Component { renderOnResizeRate: 20 }; - // TODO: this approach (||ing the visibleEditors) isn't great. - const splitCSS = visibleEditors.indexhtml && visibleEditors.indexcss; - const splitJS = - visibleEditors.indexcss || - (visibleEditors.indexhtml && visibleEditors.indexjs); + let splitterJSXRight, splitterHTMLRight, splitterCSSRight; + if (indexjsx) { + if (indexhtml || indexcss || indexjs) { + splitterJSXRight = true; + } + } + if (indexhtml) { + if (indexcss || indexjs) { + splitterHTMLRight = true; + } + } + if (indexcss) { + if (indexjs) { + splitterCSSRight = true; + } + } // TODO: tabs should be dynamically created from the challengeFiles // TODO: the tabs mess up the rendering (scroll doesn't work properly and @@ -204,7 +215,23 @@ class MultifileEditor extends Component { > - {visibleEditors.indexhtml && ( + {indexjsx && ( + + + + )} + {splitterJSXRight && ( + + )} + {indexhtml && ( )} - {splitCSS && } - {visibleEditors.indexcss && ( + {splitterHTMLRight && ( + + )} + {indexcss && ( )} - {splitJS && } + {splitterCSSRight && ( + + )} - {visibleEditors.indexjs && ( + {indexjs && ( )} - {visibleEditors.indexjsx && ( - - - - )}