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: inifinite resize (#1087)

Myles Scolnickd86851976767
diff --git a/1072.py b/1072.py
new file mode 100644
index 0000000000..1e4212140d
--- /dev/null
+++ b/1072.py
@@ -0,0 +1,22 @@
+import marimo
+
+__generated_with = "0.3.9"
+app = marimo.App(width="medium")
+
+
+def __():
+ import polars as pl
+ from sklearn.datasets import fetch_california_housing
+
+ housing = fetch_california_housing()
+ df = pl.DataFrame(
+ data=housing.data, schema=housing.feature_names
+ ).with_columns(Price=housing.target)
+
+ df.plot.scatter(x="MedInc", y="Price")
+ return df, fetch_california_housing, housing, pl
+
+
+if __name__ == "__main__":
+ app.run()
diff --git a/frontend/index.html b/frontend/index.html
index 239fae7466..ef28b43329 100644
--- a/frontend/index.html
+++ b/frontend/index.html
@@ -28,9 +28,19 @@
function setHeight() {
var element = obj.contentWindow.document.documentElement;
+ // If there is no vertical scrollbar, we don't need to resize the iframe
+ if (element.scrollHeight === element.clientHeight) {
+ return;
+ }
+
+ // Create a new height that includes the scrollbar height if it's visible
var hasHorizontalScrollbar = element.scrollWidth > element.clientWidth;
- var height = element.scrollHeight + (hasHorizontalScrollbar ? scrollbarHeight : 0);
- obj.style.height = `${height}px`;
+ var newHeight = element.scrollHeight + (hasHorizontalScrollbar ? scrollbarHeight : 0);
+
+ // Only update the height if it's different from the current height
+ if (obj.style.height !== `${newHeight}px`) {
+ obj.style.height = `${newHeight}px`;
+ }
}
// Resize the iframe to the height of the content and bottom scrollbar height