A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.
Python artificial-intelligencedagdata-sciencedata-visualizationdataflowdeveloper-toolsmachine-learningnotebookspipelinepythonreactivesqlweb-app
Support `mo.ui.matplotlib` selections from code mode (#9195)
Trevor Manz4b98fe9b489c
diff --git a/frontend/src/plugins/impl/matplotlib/matplotlib-renderer.ts b/frontend/src/plugins/impl/matplotlib/matplotlib-renderer.tsindex 2b3b1a69c0..70d85e28d1 100644--- a/frontend/src/plugins/impl/matplotlib/matplotlib-renderer.ts+++ b/frontend/src/plugins/impl/matplotlib/matplotlib-renderer.ts@@ -380,6 +380,18 @@ export class MatplotlibRenderer {return;}+ // Restore selection from backend when the value changed and the user+ // is not actively drawing/dragging/resizing. During active interactions+ // the renderer owns the interaction state — overwriting it would fight+ // the user's pointer.+ const isUserInteracting =+ this.#interaction.type !== "idle" && this.#interaction.action !== null;+ if (state.value !== prev.value && !isUserInteracting) {+ this.#restoreSelection(state.value);+ // #restoreSelection already schedules a redraw+ return;+ }+// Redraw if style props changed or dimensions changedif (needsRedraw ||@@ -576,6 +588,10 @@ export class MatplotlibRenderer {#restoreSelection = (value: SelectionValue): void => {if (!value || !("has_selection" in value) || !value.has_selection) {+ if (this.#interaction.type !== "idle") {+ this.#interaction = { type: "idle" };+ this.#scheduleRedraw();+ }return;}