-
Notifications
You must be signed in to change notification settings - Fork 6
Closed
Description
Description
While researching #76 and #93, I found the source code on what sets the dirty state.
Most "top-level" widgets (that get a dedicated tab in JupyterLab) inherit from the DocumentWidget class, which implements this method:
/**
* Handle the dirty state of the context model.
*/
private _handleDirtyState(): void {
if (
this.context.model.dirty &&
!this.title.className.includes(DIRTY_CLASS)
) {
this.title.className += ` ${DIRTY_CLASS}`;
} else {
this.title.className = this.title.className.replace(DIRTY_CLASS, '');
}
}The issue is that the document model is stored in two places: this.context.model and this.content.model. We only update this.content.model, but the dirty indicator reads from this.context.model. This is because this.context: DocumentRegistry.IContext does not provide a way to update the document model.
We ought to understand:
- What is document context, and why does it have a separate reference to the model?
- How can we stick to a single source of truth for the document model?
Metadata
Metadata
Assignees
Labels
No labels