Hid the admin sidebar for the automations/:id React route#28558
Hid the admin sidebar for the automations/:id React route#28558cmraible wants to merge 5 commits into
automations/:id React route#28558Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
WalkthroughThis PR introduces a route-aware sidebar visibility mechanism for the admin app. A new Suggested reviewers
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
| Command | Status | Duration | Result |
|---|---|---|---|
nx run @tryghost/admin-x-settings:test:acceptance |
✅ Succeeded | 10m 2s | View ↗ |
nx build @tryghost/announcement-bar |
✅ Succeeded | <1s | View ↗ |
nx build @tryghost/portal |
✅ Succeeded | <1s | View ↗ |
nx build @tryghost/activitypub |
✅ Succeeded | 1s | View ↗ |
nx build @tryghost/sodo-search |
✅ Succeeded | <1s | View ↗ |
nx build @tryghost/signup-form |
✅ Succeeded | <1s | View ↗ |
nx build @tryghost/admin-toolbar |
✅ Succeeded | <1s | View ↗ |
nx build @tryghost/comments-ui |
✅ Succeeded | <1s | View ↗ |
Additional runs (8) |
✅ Succeeded | ... | View ↗ |
💡 Verify your cache is correct by running tasks in a sandbox. Read docs ↗
☁️ Nx Cloud last updated this comment at 2026-06-12 23:17:27 UTC
ref https://linear.app/tryghost/issue/NY-1295/ - keep the React sidebar visibility helper aligned with the TypeScript style guide by using type aliases for object shapes
ref https://linear.app/tryghost/issue/NY-1295/ - avoid setting explicit undefined properties in the sidebar visibility route match test data
ref https://linear.app/tryghost/issue/NY-1295/ - avoid a type assertion when reading React Router handle metadata by narrowing the route handle before checking the sidebar flag
automations/:id React route
There was a problem hiding this comment.
🧹 Nitpick comments (1)
apps/posts/src/routes.tsx (1)
81-81: 📐 Maintainability & Code Quality | ⚡ Quick winConsider adding type safety to the route handle.
The
handleobject could benefit from a type annotation to provide IDE autocomplete and catch typos at compile time.✨ Suggested improvement with type annotation
Import the type at the top of the file:
import {ErrorPage} from '`@tryghost/shade/primitives`'; import {RouteObject, lazyComponent} from '`@tryghost/admin-x-framework`'; +import type {AdminRouteHandle} from '`@/layout/sidebar-visibility`';Then apply the type using
satisfies:{ path: ':id', - handle: {hideAdminSidebar: true}, + handle: {hideAdminSidebar: true} satisfies AdminRouteHandle, lazy: lazyComponent(() => import('`@views/Automations/editor`')) }This provides compile-time safety while preserving the runtime type checking.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@apps/posts/src/routes.tsx` at line 81, Add a type annotation for the route handle to get compile-time safety: import the appropriate Handle type used by your routing framework at the top of the file, then annotate the route's handle object (the one containing hideAdminSidebar) using either a type assertion or the "satisfies" operator so the handle conforms to that Handle type; update the route definition where handle: { hideAdminSidebar: true } is declared (in apps/posts/src/routes.tsx) to use that typed handle so IDE autocomplete and typo checking work.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@apps/posts/src/routes.tsx`:
- Line 81: Add a type annotation for the route handle to get compile-time
safety: import the appropriate Handle type used by your routing framework at the
top of the file, then annotate the route's handle object (the one containing
hideAdminSidebar) using either a type assertion or the "satisfies" operator so
the handle conforms to that Handle type; update the route definition where
handle: { hideAdminSidebar: true } is declared (in apps/posts/src/routes.tsx) to
use that typed handle so IDE autocomplete and typo checking work.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 8a5fdf89-b2bb-408b-8f80-95a352cf18f1
📒 Files selected for processing (5)
apps/admin/src/layout/admin-layout.tsxapps/admin/src/layout/app-sidebar/mobile-nav-bar.tsxapps/admin/src/layout/sidebar-visibility.test.tsxapps/admin/src/layout/sidebar-visibility.tsapps/posts/src/routes.tsx
ref https://linear.app/tryghost/issue/NY-1295/ - share the admin route handle shape through admin-x-framework so React route metadata gets compile-time checking where it is declared

closes https://linear.app/ghost/issue/NY-1295/wire-up-ability-to-toggle-admin-sidebar-just-in-react-so-its-off-for
Summary
useAdminSidebarVisibilityto combine Ember sidebar state with React route handlesWhy
The automations editor needs a fullscreen canvas. The previous CSS-only approach visually covered the admin sidebar by positioning the canvas above it, but the sidebar still existed underneath the page. That is not semantically correct: the route behaves like a sidebarless fullscreen editor, while the DOM still contains navigation that is not meant to be available on that screen.
That also creates an accessibility problem. If the sidebar remains mounted and is only visually obscured, assistive technology and keyboard navigation can still encounter sidebar links that are hidden from sighted users. The visual page and the accessibility tree can disagree about what UI is present.
This changes the sidebar behavior into a route-level layout decision. React routes can opt out with
handle: {hideAdminSidebar: true}, and the admin layout derives whether to render the sidebar from the active route matches. For the automations editor, the sidebar is no longer just covered by the canvas; it is omitted from the rendered layout for that route.The hook still respects the existing Ember bridge sidebar state so current Ember-driven fullscreen behavior, such as the post editor, keeps working while React routes gain a dedicated pattern that does not add new Ember coupling.
Testing
pnpm --filter @tryghost/admin test:unit -- src/layout/sidebar-visibility.test.tsxpnpm --filter @tryghost/admin typecheck