From 9136ea44b62c81de31a7499a03490964cc011632 Mon Sep 17 00:00:00 2001 From: Philipp Rudiger Date: Thu, 18 Apr 2024 17:47:17 +0200 Subject: [PATCH 1/3] Do not drop events while blocked --- src/widgets.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/widgets.ts b/src/widgets.ts index b615056..d08266c 100644 --- a/src/widgets.ts +++ b/src/widgets.ts @@ -83,6 +83,7 @@ export class BokehView extends DOMWidgetView { private _receiver: Receiver private _blocked: boolean private _msgs: any[] + private _events: any[] private _idle: boolean private _combine: boolean @@ -175,7 +176,7 @@ export class BokehView extends DOMWidgetView { if ( msg.msg_data.event_values.model == null || msg.msg_data.event_values.model.id != - new_msg.msg_data.event_values.model.id || + new_msg.msg_data.event_values.model.id || msg.msg_data.event_name != new_msg.msg_data.event_name ) { new_msgs.push(msg) @@ -198,6 +199,7 @@ export class BokehView extends DOMWidgetView { protected _change_event(event: DocumentChangedEvent): void { if (this._blocked) { + this._events.push(event) return } const { Serializer } = bk_require('core/serialization') @@ -228,6 +230,11 @@ export class BokehView extends DOMWidgetView { this._document.apply_json_patch(comm_msg.content, comm_msg.buffers) } finally { this._blocked = false + const events = [...this._events] + this._events = [] + for (const event of this._events) { + this._change_event(event) + } } } } From 493215b8b1bb1cafd0b5aff2fad4728d55a58368 Mon Sep 17 00:00:00 2001 From: Philipp Rudiger Date: Thu, 18 Apr 2024 17:50:52 +0200 Subject: [PATCH 2/3] Fix indentation --- src/widgets.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/widgets.ts b/src/widgets.ts index d08266c..9b7982f 100644 --- a/src/widgets.ts +++ b/src/widgets.ts @@ -230,11 +230,11 @@ export class BokehView extends DOMWidgetView { this._document.apply_json_patch(comm_msg.content, comm_msg.buffers) } finally { this._blocked = false - const events = [...this._events] - this._events = [] - for (const event of this._events) { - this._change_event(event) - } + const events = [...this._events] + this._events = [] + for (const event of this._events) { + this._change_event(event) + } } } } From 0f434a215c22c29b46f5cc22b9198faf772afeea Mon Sep 17 00:00:00 2001 From: Philipp Rudiger Date: Thu, 18 Apr 2024 17:53:34 +0200 Subject: [PATCH 3/3] Fix logic bug --- src/widgets.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/widgets.ts b/src/widgets.ts index 9b7982f..ffcbaba 100644 --- a/src/widgets.ts +++ b/src/widgets.ts @@ -232,7 +232,7 @@ export class BokehView extends DOMWidgetView { this._blocked = false const events = [...this._events] this._events = [] - for (const event of this._events) { + for (const event of events) { this._change_event(event) } }