Skip to content

Commit 0ea80af

Browse files
committed
Restore detailed comments for siteManagerIsOpen logic
1 parent 925852b commit 0ea80af

File tree

1 file changed

+15
-5
lines changed
  • packages/playground/website/src/lib/state/redux

1 file changed

+15
-5
lines changed

packages/playground/website/src/lib/state/redux/slice-ui.ts

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -127,12 +127,15 @@ export interface UIState {
127127

128128
const query = new URL(document.location.href).searchParams;
129129
const isEmbeddedInAnIframe = window.self !== window.top;
130+
// @TODO: Centralize these breakpoint sizes.
131+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
132+
const isMobile = window.innerWidth < 875;
130133

131134
// Parse the route parameter for sidebar/tab state
132135
const routeState = parseRouteParam(query.get('route'));
133136

134137
// Check if there's an explicit route param requesting the sidebar to be open.
135-
// If so, respect it regardless of viewport size (but not in seamless mode).
138+
// If so, respect it regardless of viewport size (but not in seamless mode or iframes).
136139
const hasExplicitRouteParam = query.has('route') && routeState.sidebarOpen;
137140
const isSeamlessMode = query.get('mode') === 'seamless';
138141

@@ -153,11 +156,18 @@ const initialState: UIState = {
153156
activeTab: routeState.tab || 'settings',
154157
offline: !navigator.onLine,
155158

156-
// The site manager should not be shown at all in seamless mode or in iframes.
157-
// Otherwise, if there's an explicit route param requesting it open, respect that.
158-
// If no route param, default to closed (mobile or not).
159+
// NOTE: Please do not eliminate the cases in this siteManagerIsOpen expression,
160+
// even if they seem redundant. We may experiment with toggling the manager
161+
// to be open by default or closed by default, and we do not want to lose
162+
// specific reasons for the manager to be closed.
159163
siteManagerIsOpen:
160-
!isSeamlessMode && !isEmbeddedInAnIframe && hasExplicitRouteParam,
164+
// The site manager should not be shown at all in seamless mode.
165+
!isSeamlessMode &&
166+
// We do not expect to render the Playground app UI in an iframe.
167+
!isEmbeddedInAnIframe &&
168+
// If there's an explicit route param requesting sidebar open, respect it.
169+
// Otherwise default to closed on all viewport sizes.
170+
hasExplicitRouteParam,
161171
siteManagerSection: routeState.section,
162172
};
163173

0 commit comments

Comments
 (0)