π OpenHands: AI-Driven Development
fix: keep outer container padding consistent across routes (#293)
Hiep Led968acdc3afe
diff --git a/__tests__/routes/root-layout.test.tsx b/__tests__/routes/root-layout.test.tsxindex 61ca93e0f3..1607209b95 100644--- a/__tests__/routes/root-layout.test.tsx+++ b/__tests__/routes/root-layout.test.tsx@@ -143,36 +143,25 @@ describe("root layout", () => {expect(migrateUserConsentMock).toHaveBeenCalled();});- it.each([- ["/automations"],- ["/automations/abc-123"],- ["/conversations"],- ["/conversations/abc-123"],- ])(- "drops the outer layout padding on %s so the page can render flush to the viewport edges",- (path) => {- render(+ it("renders an identical root-layout className across routes so navigation never shifts the outer container", () => {+ const paths = [+ "/",+ "/automations/abc-123",+ "/conversations/abc-123",+ "/settings",+ ];++ const classNames = paths.map((path) => {+ const { unmount } = render(<QueryClientProvider client={new QueryClient()}><RouterStub initialEntries={[path]} /></QueryClientProvider>,);+ const { className } = screen.getByTestId("root-layout");+ unmount();+ return className;+ });- const layout = screen.getByTestId("root-layout");- expect(layout.className).not.toMatch(/(^|\s)md:p-3(\s|$)/);- expect(layout.className).not.toMatch(/(^|\s)md:pl-0(\s|$)/);- expect(layout.className).not.toMatch(/(^|\s)md:pr-3(\s|$)/);- },- );-- it("keeps the outer layout padding on routes other than home and automations", () => {- render(- <QueryClientProvider client={new QueryClient()}>- <RouterStub initialEntries={["/settings"]} />- </QueryClientProvider>,- );-- const layout = screen.getByTestId("root-layout");- expect(layout.className).toMatch(/(^|\s)md:p-3(\s|$)/);- expect(layout.className).toMatch(/(^|\s)md:pl-0(\s|$)/);+ expect(new Set(classNames).size).toBe(1);});});diff --git a/src/routes/root-layout.tsx b/src/routes/root-layout.tsxindex 3240824abb..a891c18278 100644--- a/src/routes/root-layout.tsx+++ b/src/routes/root-layout.tsx@@ -1,10 +1,5 @@import React from "react";-import {- useRouteError,- isRouteErrorResponse,- Outlet,- useLocation,-} from "react-router";+import { useRouteError, isRouteErrorResponse, Outlet } from "react-router";import { useTranslation } from "react-i18next";import { I18nKey } from "#/i18n/declaration";import i18n from "#/i18n";@@ -13,7 +8,6 @@ import { Sidebar } from "#/components/features/sidebar/sidebar";import { useSettings } from "#/hooks/query/use-settings";import { useMigrateUserConsent } from "#/hooks/use-migrate-user-consent";import { useSyncPostHogConsent } from "#/hooks/use-sync-posthog-consent";-import { cn } from "#/utils/utils";import { LoadingSpinner } from "#/components/shared/loading-spinner";import { useAppTitle } from "#/hooks/use-app-title";import { ReactRouterNavigationProvider } from "./react-router-navigation-provider";@@ -70,7 +64,6 @@ export function ErrorBoundary() {export default function MainApp() {const appTitle = useAppTitle();- const { pathname } = useLocation();const { data: settings } = useSettings();const { migrateUserConsent } = useMigrateUserConsent();const config = useConfig();@@ -105,23 +98,11 @@ export default function MainApp() {);}- let rootLayoutPaddingClass = "p-0 md:p-3 md:pl-0";- if (- pathname === "/" ||- pathname.startsWith("/automations") ||- pathname.startsWith("/conversations")- ) {- rootLayoutPaddingClass = "p-0";- }-return (<ReactRouterNavigationProvider><divdata-testid="root-layout"- className={cn(- "h-screen lg:min-w-5xl flex flex-col md:flex-row bg-base overflow-hidden",- rootLayoutPaddingClass,- )}+ className="h-screen lg:min-w-5xl flex flex-col md:flex-row bg-base overflow-hidden p-0"><title>{appTitle}</title><Sidebar />