fix(ui): persist nav open state and honor preference at sidebar widths - #17733
Open
vikas-x7 wants to merge 1 commit into
Open
fix(ui): persist nav open state and honor preference at sidebar widths#17733vikas-x7 wants to merge 1 commit into
vikas-x7 wants to merge 1 commit into
Conversation
Previously the nav was force-closed at <=1440px (the l breakpoint) even though that range renders the nav as a sidebar, not a modal. The stored nav preference was only read above 1440px, and toggling the nav never wrote the preference at all after NavToggler was removed. Now the nav is only force-closed at the genuinely modal widths (m/s), the preference is read on every sidebar width, and toggling persists the preference via PREFERENCE_KEYS.NAV (merge: true) from the AppHeader sidebar toggle. Fixes payloadcms#17531
vikas-x7
requested review from
AlessioGr,
JarrodMFlesch and
jacobsfletch
as code owners
August 10, 2026 03:30
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What?
The admin nav was force-closed at viewports ≤1440px (
lbreakpoint) even though that range renders the nav as a sidebar, not a modal. The stored nav preference was only read above 1440px, and toggling the nav never wrote the preference at all (the v3NavTogglerthat handled this was removed in #17212).Fixes #17531
Why?
On any project whose desktop breakpoint is 1440px, the sidebar was never open on first load, the user's saved preference was ignored, and "remember my choice" did not exist. The unconditional close effect used the
lbreakpoint, but the comment/behaviour is about modal widths only.How?
packages/ui/src/elements/Nav/context.tsx:largeBreak === falsetomidBreak === false && smallBreak === false.midBreak === true || smallBreak === true. Thelbreakpoint (1440px) is no longer treated as a modal width.packages/ui/src/elements/AppHeader/index.tsx:setPreference(PREFERENCE_KEYS.NAV, { open }, true)(same pattern the v3NavTogglerused,merge: truepreserves nav-group prefs), gated to sidebar widths only so programmatic/modal closes are not persisted.Tests
test/admin/e2e/general/e2e.spec.ts(nav — should be open by default at sidebar widths and persist the toggle preference) at 1280px: asserts nav is open by default, and that closing/reopening + reload persists.openNav/closeNave2e helpers already handle both default states, so the viewport change does not break the surrounding tests.tsc -p packages/ui/tsconfig.json --noEmit): 0 errors.