Skip to content

Commit 10685e0

Browse files
Contextmenuandcrash (#21)
* Prevent contextmenu on applets * Fix crash, if model is not present
1 parent 49f1dac commit 10685e0

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

packages/applet-view/src/avoutputarea.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,9 @@ export class AppletViewOutputArea extends AccordionPanel {
205205
}
206206
const app = this.widgets[appIndex] as Panel;
207207
const clone = this.cloneCell(cell, cellid);
208+
clone.node.addEventListener('contextmenu', e => {
209+
e.preventDefault();
210+
});
208211
this.addToObserver(appIndex, clone);
209212
app.addWidget(clone);
210213

packages/interceptor/src/index.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,15 +83,15 @@ export class AppletWidgetRegistry implements IAppletWidgetRegistry {
8383
}
8484
}
8585

86-
getModelId(path: string) {
86+
getModelId(path: string): string | undefined {
8787
return this._pathToModelId[path];
8888
}
8989

90-
getModel(path: string) {
90+
getModel(path: string): WidgetModel | undefined {
9191
return this._pathToModel[path];
9292
}
9393

94-
getPath(modelId: string) {
94+
getPath(modelId: string): string | undefined {
9595
return this._modelIdToPath[modelId];
9696
}
9797

@@ -169,6 +169,10 @@ function activateWidgetInterceptor(
169169
) => {
170170
// const modelId = wRegistry.getModelId(args.path);
171171
const model = wRegistry.getModel(args.path);
172+
if (!model) {
173+
// just skip
174+
return;
175+
}
172176
const state = await (
173177
model.constructor as typeof WidgetModel
174178
)._deserialize_state(args.state, model.widget_manager);

0 commit comments

Comments
 (0)