Skip to content

Commit eb96879

Browse files
author
Ives van Hoorne
committed
Fix embed editing
1 parent 7829846 commit eb96879

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

src/embed/components/Content.js

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -202,18 +202,24 @@ export default class Content extends React.PureComponent {
202202

203203
if (!mainModule) throw new Error('Cannot find main module');
204204

205+
// The altered module is the same module, but with updated code (based on)
206+
// changes by the user. We need to use this to reflect changes
207+
const alteredMainModule = alteredModules.find(m => m.id === mainModule.id);
208+
209+
if (!alteredMainModule) throw new Error('Cannot find main module');
210+
205211
return (
206212
<Container>
207213
{showEditor &&
208214
<Split show={showEditor} only={showEditor && !showPreview}>
209215
<CodeEditor
210-
code={mainModule.code}
211-
id={mainModule.id}
212-
title={mainModule.title}
216+
code={alteredMainModule.code}
217+
id={alteredMainModule.id}
218+
title={alteredMainModule.title}
213219
modulePath={getModulePath(
214220
alteredModules,
215221
sandbox.directories,
216-
mainModule.id,
222+
alteredMainModule.id,
217223
)}
218224
changeCode={this.setCode}
219225
preferences={this.getPreferences()}
@@ -229,7 +235,7 @@ export default class Content extends React.PureComponent {
229235
directories={sandbox.directories}
230236
bundle={this.state.bundle}
231237
externalResources={sandbox.externalResources}
232-
module={mainModule}
238+
module={alteredMainModule}
233239
fetchBundle={this.fetchBundle}
234240
addError={this.addError}
235241
clearErrors={this.clearErrors}

0 commit comments

Comments
 (0)