Skip to content

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.

Fix: form internal value (#841)

Akshay Agrawal465c7f697664
diff --git a/frontend/src/plugins/impl/FormPlugin.tsx b/frontend/src/plugins/impl/FormPlugin.tsx
index 1fa1d80e3a..7f21541e59 100644
--- a/frontend/src/plugins/impl/FormPlugin.tsx
+++ b/frontend/src/plugins/impl/FormPlugin.tsx
@@ -225,6 +225,14 @@ const Form = ({
setInternalValue(UI_ELEMENT_REGISTRY.lookupValue(elementId));
}, [elementId]);
+ // Edge case: the Form plugin may be re-created in Python with the same
+ // wrapped `elementId`, meaning the value of the wrapped element
+ // can change without the plugin generating an event
+ const wrappedValue = UI_ELEMENT_REGISTRY.lookupValue(elementId);
+ if (wrappedValue !== internalValue) {
+ setInternalValue(wrappedValue);
+ }
+
useEffect(() => {
// Spy on when the plugin generates an event (MarimoValueInputEvent)
const handleUpdate = (e: MarimoValueInputEventType) => {