Skip to content

Commit 892a3cc

Browse files
committed
fix: make sure initial changes to the model are applied to what is needed [PIE-439]
1 parent 68850d0 commit 892a3cc

2 files changed

Lines changed: 16 additions & 7 deletions

File tree

packages/multiple-choice/configure/src/index.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,10 @@ export default class MultipleChoice extends HTMLElement {
137137
}
138138

139139
onModelChanged(m, reset) {
140-
this._model = m;
140+
this._model = {
141+
...this._model,
142+
...m,
143+
};
141144
this._render();
142145

143146
this.dispatchModelUpdated(reset);

packages/multiple-choice/configure/src/main.jsx

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,9 @@ export class Main extends React.Component {
381381
}
382382

383383
model.choices.splice(index, 1);
384-
onModelChanged(model);
384+
onModelChanged({
385+
choices: model.choices,
386+
});
385387
};
386388

387389
onAddChoice = () => {
@@ -407,7 +409,9 @@ export class Main extends React.Component {
407409
feedback: { type: 'none' },
408410
});
409411

410-
onModelChanged(model);
412+
onModelChanged({
413+
choices: model.choices,
414+
});
411415
};
412416

413417
onChoiceChanged = (index, choice) => {
@@ -418,19 +422,19 @@ export class Main extends React.Component {
418422
}
419423

420424
model.choices.splice(index, 1, choice);
421-
onModelChanged(model);
425+
onModelChanged({
426+
choices: model.choices,
427+
});
422428
};
423429

424430
onPromptChanged = (prompt) => {
425431
this.props.onModelChanged({
426-
...this.props.model,
427432
prompt,
428433
});
429434
};
430435

431436
onTeacherInstructionsChanged = (teacherInstructions) => {
432437
this.props.onModelChanged({
433-
...this.props.model,
434438
teacherInstructions,
435439
});
436440
};
@@ -460,7 +464,9 @@ export class Main extends React.Component {
460464
});
461465
}
462466

463-
onModelChanged(model, true);
467+
onModelChanged({
468+
choices: model.choices,
469+
}, true);
464470
break;
465471
}
466472

0 commit comments

Comments
 (0)