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 image_compare expand output bug (#10907)

Martha Cryan50e686042eb4
diff --git a/frontend/src/plugins/impl/image-comparison/ImageComparisonComponent.tsx b/frontend/src/plugins/impl/image-comparison/ImageComparisonComponent.tsx
index e34015cddf..968f626fbe 100644
--- a/frontend/src/plugins/impl/image-comparison/ImageComparisonComponent.tsx
+++ b/frontend/src/plugins/impl/image-comparison/ImageComparisonComponent.tsx
@@ -41,7 +41,7 @@ const ImageComparisonComponent: React.FC<ImageComparisonData> = ({
const containerStyle: React.CSSProperties = {
width: width || "100%",
- height: height || (direction === "vertical" ? "400px" : "auto"),
+ height: height || "auto",
maxWidth: "100%",
// The slider derives its height entirely from its (loaded) images, so a
// broken/slow-loading source would otherwise collapse it to nothing and
diff --git a/frontend/src/plugins/impl/image-comparison/__tests__/ImageComparisonComponent.test.tsx b/frontend/src/plugins/impl/image-comparison/__tests__/ImageComparisonComponent.test.tsx
index acedab40fe..4d5d0f0a44 100644
--- a/frontend/src/plugins/impl/image-comparison/__tests__/ImageComparisonComponent.test.tsx
+++ b/frontend/src/plugins/impl/image-comparison/__tests__/ImageComparisonComponent.test.tsx
@@ -115,6 +115,21 @@ describe("ImageComparisonComponent", () => {
}
});
+ it.each(["horizontal", "vertical"] as const)(
+ "lets the container grow to the images when no height is given (%s)",
+ (direction) => {
+ const { container } = render(
+ <ImageComparisonComponent {...baseProps} direction={direction} />,
+ );
+
+ // A fixed height would crop tall images and leave the output's expand
+ // button with nothing to reveal.
+ const slider = container.querySelector("img-comparison-slider");
+ expect(slider).toBeTruthy();
+ expect(slider?.parentElement?.style.height).toBe("auto");
+ },
+ );
+
it("leaves images unstyled when no dimensions are given", () => {
const { getAllByAltText } = render(
<ImageComparisonComponent {...baseProps} />,