Skip to content

Commit

Permalink
Correct dirty handling in notebook model (#13358)
Browse files Browse the repository at this point in the history
  • Loading branch information
fcollonval committed Nov 2, 2022
1 parent a9de96c commit cfc7bf5
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions packages/notebook/src/model.ts
Expand Up @@ -362,13 +362,17 @@ close the notebook without saving it.`,
): void {
if (changes.stateChange) {
changes.stateChange.forEach(value => {
if (value.name !== 'dirty' || this._dirty !== value.newValue) {
this._dirty = value.newValue;
this.triggerStateChange({
newValue: undefined,
oldValue: undefined,
...value
});
if (value.oldValue !== value.newValue) {
if (value.name === 'dirty') {
// Setting `dirty` will trigger the state change.
this.dirty = value.newValue;
} else {
this.triggerStateChange({
newValue: undefined,
oldValue: undefined,
...value
});
}
}
});
}
Expand Down

0 comments on commit cfc7bf5

Please sign in to comment.