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 matrix widget showing stale values after cell re-execution (#8507)

Trevor Manz6f06f365fce5
diff --git a/frontend/src/plugins/impl/MatrixPlugin.tsx b/frontend/src/plugins/impl/MatrixPlugin.tsx
index ba23287649..b6a0226532 100644
--- a/frontend/src/plugins/impl/MatrixPlugin.tsx
+++ b/frontend/src/plugins/impl/MatrixPlugin.tsx
@@ -1,5 +1,5 @@
/* Copyright 2026 Marimo. All rights reserved. */
-import { type JSX, useCallback, useRef, useState } from "react";
+import { type JSX, useCallback, useEffect, useRef, useState } from "react";
import { z } from "zod";
import { cn } from "@/utils/cn";
import type { IPlugin, IPluginProps, Setter } from "../types";
@@ -90,6 +90,9 @@ const MatrixComponent = ({
// Outside of a drag we always read from the prop `value` directly,
// which avoids stale-state bugs when the matrix shape changes.
const [draft, setDraft] = useState(value);
+ useEffect(() => {
+ setDraft(value);
+ }, [value]);
const displayValue = activeCell == null ? value : draft;
const formatValue = (val: number) =>