JCU/fix(root): resolve the admin-sidebar gutter in CSS, not in an animation - #1496
Merged
Merged
Conversation
…mation Backport of #1333, already on customer/TUL, customer/lindat and customer/mendelu. Written for this branch rather than cherry-picked. @slideSidebarPadding reads the gutter width from the browser-only CSS-variable store, so the server has nothing to substitute and renders style="padding-left: *", which is not valid CSS. For a logged-in user the browser then resolves the real width and the page moves right by the sidebar. That is visible on every reload, and all the more so now that the anti-flicker overlay holds the server's paint on screen while it happens. The gutter now comes from a ds-admin-sidebar-{hidden,unpinned,pinned} class whose padding-left reads --ds-admin-sidebar-fixed-element-width / --ds-admin-sidebar-total-width. CSS resolves those the same on the server and in the browser, so there is nothing left to shift and no width is hardcoded. The pin/unpin slide survives as transition: padding-left, gated behind ds-admin-sidebar-animate, which is added only after the first paint so the initial resolution never animates. Measured on the docker stack, logged in, reloading /home: outer-wrapper padding-left goes from "padding-left: *" (computed 0px, sidebar overlapping the content) to 55px, identical in the SSR snapshot and the live app, and the horizontal position of #main-content no longer moves at all. Refs: dataquest-dev/dspace-customers#717 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.
References
Description
Logged in as an administrator, a reload moved the whole page sideways.
@slideSidebarPaddingtakes the gutter width from the browser-only CSS-variable store, so the server has nothing to substitute and rendersstyle="padding-left: *", which is not valid CSS. The browser then resolves the real width and everything shifts right by the sidebar. The gutter is now resolved in CSS from the sidebar's own custom properties, which the server and the browser read the same way.Instructions for Reviewers
List of changes in this PR:
root.component.html: the@slideSidebarPaddingbinding is replaced byds-admin-sidebar-{hidden,unpinned,pinned}classes, driven by a newsidebarPaddingState$.root.component.scss: those classes resolvepadding-leftfrom--ds-admin-sidebar-fixed-element-widthand--ds-admin-sidebar-total-width, the same custom properties the animation used to read. No width is hardcoded and the theme keeps control of it.transition: padding-left, behindds-admin-sidebar-animate, whichngAfterViewInitadds after the first paint so the initial resolution never animates.themes/custom/app/root/root.component.tsdrops the animation as well.Written for this branch rather than cherry-picked, since #1333 landed on 7.x. The changed blocks match customer/mendelu's line for line apart from comment wording.
#1493 made this worth fixing now rather than later: the anti-flicker overlay holds the server's paint on screen for a second or two, so the shift that used to be lost in the white rebuild is now a clean jump the eye follows.
How to test:
view-source:on a page served to a logged-in session:.outer-wrappercarriesds-admin-sidebar-unpinnedand no inlinestyleattribute. It used to readstyle="padding-left: *"..outer-wrappercarriesds-admin-sidebar-hiddenand the gutter is 0.Measured on a DSpace 9.3 stack in Docker (
docker-compose-rest.yml+db.entities.yml, 494 items) with this branch's production build under PM2, logged in as an administrator, reloading/homeat 4x CPU throttle:.outer-wrapperinline stylepadding-left: *padding-left0px55px#main-contentx--ds-admin-sidebar-fixed-element-widthresolves to 55px and--ds-admin-sidebar-total-widthto 305px in the browser, sopinnedkeeps the width the animation used. Anonymous pages are unchanged:ds-admin-sidebar-hidden, gutter 0, and the white-frame numbers from #1493 still hold (89-104ms document-swap gap with the overlay, 407-842ms extra flash without it).Checklist
mainbranch of code (unless it is a backport or is fixing an issue specific to an older branch). Customer branch fix, base iscustomer/jcu.npm run lintnpm run check-circ-deps)root.component.spec.tspasses; the behaviour itself is CSS, verified on a running stack.package.json), I've made sure their licenses align with the DSpace BSD License. None added.