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
Dispatch resize event when config width changes (#295)
Myles Scolnick01cac3530190
diff --git a/frontend/src/components/app-config/app-config-form.tsx b/frontend/src/components/app-config/app-config-form.tsxindex 5e02ee2ae7..215740b43d 100644--- a/frontend/src/components/app-config/app-config-form.tsx+++ b/frontend/src/components/app-config/app-config-form.tsx@@ -14,6 +14,7 @@ import { useAppConfig } from "@/core/state/config";import { Switch } from "@/components/ui/switch";import { saveAppConfig } from "@/core/network/requests";import { SettingTitle, SettingDescription } from "./common";+import { useEffect } from "react";export const AppConfigForm: React.FC = () => {const [config, setConfig] = useAppConfig();@@ -35,6 +36,11 @@ export const AppConfigForm: React.FC = () => {});};+ // When width is changed, dispatch a resize event so widgets know to resize+ useEffect(() => {+ window.dispatchEvent(new Event("resize"));+ }, [config.width]);+return (<Form {...form}><form@@ -55,7 +61,7 @@ export const AppConfigForm: React.FC = () => {checked={field.value === "full"}size="sm"onCheckedChange={(checked) => {- return field.onChange(checked === true ? "full" : "normal");+ field.onChange(checked === true ? "full" : "normal");}}/></FormControl>diff --git a/frontend/src/css/index.css b/frontend/src/css/index.cssindex 4563b8c5a5..e1e76a47e8 100644--- a/frontend/src/css/index.css+++ b/frontend/src/css/index.css@@ -23,7 +23,6 @@ body {body,#root {- height: 100vh;width: 100%;display: flex;flex-direction: column;diff --git a/frontend/src/editor/chrome/wrapper/app-chrome.tsx b/frontend/src/editor/chrome/wrapper/app-chrome.tsxindex 93f885a248..4adec8de30 100644--- a/frontend/src/editor/chrome/wrapper/app-chrome.tsx+++ b/frontend/src/editor/chrome/wrapper/app-chrome.tsx@@ -39,6 +39,15 @@ export const AppChrome: React.FC<PropsWithChildren> = ({ children }) => {if (!isOpen && !isCurrentlyCollapsed) {sidebarRef.current.collapse();}++ // Dispatch a resize event so widgets know to resize+ requestAnimationFrame(() => {+ // HACK: Unfortunately, we have to do this twice to make sure it the+ // panel is fully expanded before we dispatch the resize event+ requestAnimationFrame(() => {+ window.dispatchEvent(new Event("resize"));+ });+ });}, [isOpen]);const appBody = (@@ -49,6 +58,12 @@ export const AppChrome: React.FC<PropsWithChildren> = ({ children }) => {const resizeHandle = (<PanelResizeHandle+ onDragging={(isDragging) => {+ if (!isDragging) {+ // Once the user is done dragging, dispatch a resize event+ window.dispatchEvent(new Event("resize"));+ }+ }}className={cn("border-border no-print",isOpen ? "resize-handle" : "resize-handle-collapsed",@@ -121,7 +136,7 @@ export const AppChrome: React.FC<PropsWithChildren> = ({ children }) => {);return (- <div className="flex flex-col flex-1 overflow-hidden">+ <div className="flex flex-col flex-1 overflow-hidden absolute inset-0"><PanelGroupkey={panelLocation}autoSaveId={`marimo:chrome`}