diff --git a/.kiro/specs/sidebar-font-style-flicker-fix/bugfix.md b/.kiro/specs/sidebar-font-style-flicker-fix/bugfix.md new file mode 100644 index 000000000000..9ed853e919b0 --- /dev/null +++ b/.kiro/specs/sidebar-font-style-flicker-fix/bugfix.md @@ -0,0 +1,45 @@ +# Bugfix Requirements Document + +## Introduction + +The left sidebar navigation on documentation pages exhibits inconsistent font styling during scrolling. Navigation items randomly render with different font weights or styles when scrolling, particularly when scrolling upward from lower sections of the page. The styling typically self-corrects after a few seconds, but this flickering behavior creates a poor user experience and indicates potential issues with rendering or state management during scroll events. + +## Bug Analysis + +### Current Behavior (Defect) + +1.1 WHEN the user scrolls through a documentation page THEN sidebar navigation items occasionally render with inconsistent font styling 1.2 WHEN the user scrolls upward from lower sections of the page THEN the sidebar font weight or style temporarily changes from the expected appearance 1.3 WHEN the user continues scrolling or waits a few seconds THEN the sidebar styling spontaneously corrects itself without user interaction + +### Expected Behavior (Correct) + +2.1 WHEN the user scrolls through a documentation page THEN sidebar navigation items SHALL maintain consistent font family, font size, and font weight throughout the scroll operation 2.2 WHEN the user scrolls upward from lower sections of the page THEN the sidebar SHALL continue rendering with stable, expected font styling without temporary changes 2.3 WHEN the user scrolls THEN sidebar styling SHALL remain visually consistent and not flicker or change unexpectedly + +### Unchanged Behavior (Regression Prevention) + +3.1 WHEN the page is not scrolling THEN the sidebar SHALL CONTINUE TO display all navigation items with correct font styling 3.2 WHEN the user clicks on a sidebar navigation item THEN the sidebar SHALL CONTINUE TO update selection state and navigate to the target section 3.3 WHEN the user scrolls to the top or bottom of the page THEN the sidebar SHALL CONTINUE TO function normally without any rendering issues + +## Root Cause Analysis + +### Investigation Findings + +1. **CSS Layer Compositing & `will-change: width`**: The `.docSidebarContainer` class in `packages/docusaurus-theme-classic/src/theme/DocRoot/Layout/Sidebar/styles.module.css` had `will-change: width` declared to optimize width collapse transitions. +2. **GPU Rasterization & Subpixel Font Smoothing**: In Chromium-based browsers (Chrome, Edge), promoting `.docSidebarContainer` to an isolated compositing layer causes text within child nodes to alternate between grayscale anti-aliasing and subpixel LCD anti-aliasing during scroll-linked repaint phases. +3. **Scroll-Triggered Repaint Cycle**: As the main content viewport scrolls, Chromium recalculates clip paths and layer boundaries. This causes navigation links within the sticky sidebar to temporarily render with altered font weight/sharpness before settling back, producing visible flicker. +4. **Resolution**: Removing `will-change: width` prevents unnecessary permanent GPU layer promotion. CSS `transition: width` performs smoothly without forcing persistent compositing layers that degrade text rasterization. + +## Verification & Test Plan + +### Browser Compatibility Matrix + +| Browser Engine | Target Browsers | Pre-Fix Behavior | Post-Fix Behavior | +| :-- | :-- | :-- | :-- | +| **Blink / Chromium** | Chrome, Edge, Brave | Inconsistent font smoothing & weight jitter on scroll | Stable font rendering; smooth width collapse | +| **Gecko** | Firefox | Stable (no visible font jitter observed) | Continues stable rendering; smooth transition | +| **WebKit** | Safari | Occasional layer boundary clipping glitch | Clean rendering without clipping artifacts | + +### Manual Verification Steps + +1. Navigate to a documentation page with a long scrollable body and nested sidebar categories. +2. Rapidly scroll down to the bottom of the page, then scroll upward through mid-sections. +3. Observe the left sidebar navigation items: font weight, size, and antialiasing remain static. +4. Click the sidebar collapse/expand toggle button: confirm the smooth animation completes without frame drops. diff --git a/.kiro/specs/sidebar-font-style-flicker-fix/tasks.md b/.kiro/specs/sidebar-font-style-flicker-fix/tasks.md new file mode 100644 index 000000000000..be86ca58e820 --- /dev/null +++ b/.kiro/specs/sidebar-font-style-flicker-fix/tasks.md @@ -0,0 +1,12 @@ +# Implementation Tasks: Sidebar Font Style Flicker Fix + +- [x] 1. Root Cause Analysis + - [x] 1.1 Trace GPU layer promotion on `.docSidebarContainer` in responsive layout + - [x] 1.2 Identify interaction between `will-change: width` and Chromium subpixel anti-aliasing during scroll repaints +- [x] 2. Theme Classic CSS Optimization + - [x] 2.1 Remove `will-change: width` declaration from `.docSidebarContainer` in `styles.module.css` + - [x] 2.2 Add explanatory code comment preventing future regressions +- [x] 3. Verification & Validation + - [x] 3.1 Validate smooth collapse/expand transition on desktop viewports (>=997px) + - [x] 3.2 Verify font rendering stability across scroll-up and scroll-down events in Blink/Chromium + - [x] 3.3 Confirm zero regressions in Gecko (Firefox) and WebKit (Safari) diff --git a/packages/docusaurus-theme-classic/src/theme/DocRoot/Layout/Sidebar/styles.module.css b/packages/docusaurus-theme-classic/src/theme/DocRoot/Layout/Sidebar/styles.module.css index 97903b7cec02..235567986846 100644 --- a/packages/docusaurus-theme-classic/src/theme/DocRoot/Layout/Sidebar/styles.module.css +++ b/packages/docusaurus-theme-classic/src/theme/DocRoot/Layout/Sidebar/styles.module.css @@ -20,7 +20,10 @@ width: var(--doc-sidebar-width); margin-top: calc(-1 * var(--ifm-navbar-height)); border-right: 1px solid var(--ifm-toc-border-color); - will-change: width; + /* + * Do not set `will-change: width` here: creating a permanent compositing layer + * causes subpixel font-smoothing artifacts and font flickering during page scroll in Chromium. + */ transition: width var(--ifm-transition-fast) ease; clip-path: inset(0); }