Skip to content

Commit 18cbce4

Browse files
Fix missing divider when html collapsed (#2187)
* Use the index (as idx) optional argument to forEach to test position in the array. * Renaming index to languageIndex and idx to visibleLanguagesIndex Co-authored-by: Mat Brown <mat.a.brown@gmail.com>
1 parent da3cbe0 commit 18cbce4

File tree

1 file changed

+43
-41
lines changed

1 file changed

+43
-41
lines changed

src/components/EditorsColumn.jsx

Lines changed: 43 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -39,52 +39,54 @@ export default function EditorsColumn({
3939

4040
const editors = [];
4141

42-
visibleLanguages.forEach(({language, index}) => {
43-
editors.push(
44-
<EditorContainer
45-
key={language}
46-
language={language}
47-
ref={resizableFlexRefs[index]}
48-
source={currentProject.sources[language]}
49-
style={{flexGrow: resizableFlexGrow.get(index)}}
50-
onHide={partial(
51-
onComponentHide,
52-
currentProject.projectKey,
53-
`editor.${language}`,
54-
)}
55-
>
56-
<Editor
57-
errors={errors[language].items}
42+
visibleLanguages.forEach(
43+
({language, index: languageIndex}, visibleLanguagesIndex) => {
44+
editors.push(
45+
<EditorContainer
46+
key={language}
5847
language={language}
59-
percentageOfHeight={1 / visibleLanguages.length}
60-
projectKey={currentProject.projectKey}
61-
requestedFocusedLine={requestedFocusedLine}
48+
ref={resizableFlexRefs[languageIndex]}
6249
source={currentProject.sources[language]}
63-
textSizeIsLarge={isTextSizeLarge}
64-
useCodeMirror={isExperimental}
65-
onAutoFormat={onAutoFormat}
66-
onInput={handleInputForLanguage(language)}
67-
onReady={partial(onEditorReady, language)}
68-
onRequestedLineFocused={onRequestedLineFocused}
69-
onSave={onSave}
70-
/>
71-
</EditorContainer>,
72-
);
73-
if (index < visibleLanguages.length - 1) {
74-
editors.push(
75-
<DraggableCore
76-
key={`divider:${language}`}
77-
onDrag={partial(onResizableFlexDividerDrag, index)}
50+
style={{flexGrow: resizableFlexGrow.get(languageIndex)}}
51+
onHide={partial(
52+
onComponentHide,
53+
currentProject.projectKey,
54+
`editor.${language}`,
55+
)}
7856
>
79-
<div
80-
className={classnames('editors__row-divider', {
81-
'editors__row-divider_draggable': isFlexResizingSupported,
82-
})}
57+
<Editor
58+
errors={errors[language].items}
59+
language={language}
60+
percentageOfHeight={1 / visibleLanguages.length}
61+
projectKey={currentProject.projectKey}
62+
requestedFocusedLine={requestedFocusedLine}
63+
source={currentProject.sources[language]}
64+
textSizeIsLarge={isTextSizeLarge}
65+
useCodeMirror={isExperimental}
66+
onAutoFormat={onAutoFormat}
67+
onInput={handleInputForLanguage(language)}
68+
onReady={partial(onEditorReady, language)}
69+
onRequestedLineFocused={onRequestedLineFocused}
70+
onSave={onSave}
8371
/>
84-
</DraggableCore>,
72+
</EditorContainer>,
8573
);
86-
}
87-
});
74+
if (visibleLanguagesIndex < visibleLanguages.length - 1) {
75+
editors.push(
76+
<DraggableCore
77+
key={`divider:${language}`}
78+
onDrag={partial(onResizableFlexDividerDrag, languageIndex)}
79+
>
80+
<div
81+
className={classnames('editors__row-divider', {
82+
'editors__row-divider_draggable': isFlexResizingSupported,
83+
})}
84+
/>
85+
</DraggableCore>,
86+
);
87+
}
88+
},
89+
);
8890

8991
if (isEmpty(editors)) {
9092
return null;

0 commit comments

Comments
 (0)