Skip to content

Fix sidebar size and state on orientation change- Preserves sidebar s…#2219

Open
Elitex07 wants to merge 8 commits into
Acode-Foundation:mainfrom
Elitex07:fix-sidebar-orientation
Open

Fix sidebar size and state on orientation change- Preserves sidebar s…#2219
Elitex07 wants to merge 8 commits into
Acode-Foundation:mainfrom
Elitex07:fix-sidebar-orientation

Conversation

@Elitex07

@Elitex07 Elitex07 commented Jun 14, 2026

Copy link
Copy Markdown
Contributor

…tate when rotating- Adjusts sidebar widths for landscape and portrait modes- Prevents animation flash on rotation

Fixes: #2195

…tate when rotating- Adjusts sidebar widths for landscape and portrait modes- Prevents animation flash on rotationFixes Acode-Foundation#2195
@greptile-apps

greptile-apps Bot commented Jun 14, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR addresses a reported bug where the sidebar's open/closed state and dimensions were not correctly preserved across device orientation changes. It rewrites the onWindowResize handler to snapshot the pre-rotation state, perform mode-appropriate teardown inline, and conditionally reopen the sidebar in landscape mode.

  • Sidebar state restoration: Introduces wasOpenInTab and hideTimeout flags to remember whether the sidebar was open before rotating to portrait, and attempts to restore it when rotating back to landscape — but the flag is erased by hide() before shouldShow can read it, so restoration silently fails on the portrait\u2192landscape path.
  • Dimension adjustments: Sidebar CSS and getWidth() updated from 70vw/350px caps to 60vw/300px, mode threshold raised from 600px to 750px to better reflect landscape breakpoints.
  • Editor scroller: willChange: \"transform\" and contentVisibility: \"auto\" added to the CodeMirror scroller theme to prevent animation flash, with potential side-effects on CodeMirror's DOM measurement APIs and GPU memory usage.

Confidence Score: 3/5

The orientation-change state restoration — the PR's primary goal — does not work on the portrait→landscape path due to the flag being cleared during cleanup.

The wasOpenInTab flag that encodes 'sidebar was open before rotating to portrait' is reset inside hide() during the portrait→landscape cleanup step, before shouldShow evaluates it. The sidebar never reopens in landscape mode after a round-trip rotation without user interaction in portrait — the exact scenario the PR aims to fix.

src/components/sidebar/index.js — specifically the onWindowResize handler around shouldShow and the interaction between hide() clearing wasOpenInTab and its use in the restoration logic.

Important Files Changed

Filename Overview
src/components/sidebar/index.js Core orientation-change logic rewritten — new wasOpenInTab flag is wiped by hide() before shouldShow evaluates it, breaking state restoration on portrait→landscape rotation; also adds hideTimeout tracking and improved cleanup for phone-mode teardown.
src/cm/mainEditorExtensions.ts Adds willChange: "transform" and contentVisibility: "auto" to the CodeMirror scroller theme; both properties may have unintended side effects with CodeMirror's internal DOM measurement and GPU memory allocation.
src/components/sidebar/style.scss Adjusts base sidebar dimensions from 70vw/350px to 60vw/300px and removes the now-redundant .tab { max-width: 250px } override; straightforward CSS-only change.
AGENTS.md New contributor guidelines file documenting project structure, build commands, and coding conventions — documentation-only addition.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[onWindowResize fires] --> B{innerWidth changed?}
    B -- No --> Z[return]
    B -- Yes --> C[snapshot wasActivated & previousMode]
    C --> D{previousMode === 'tab'?}
    D -- Yes --> E[wasOpenInTab = wasActivated && sidebarShown==='1']
    D -- No --> F[wasOpenInTab unchanged]
    E --> G{wasActivated?}
    F --> G
    G -- Yes, phone --> H[Inline phone cleanup: remove element, call onhide]
    G -- Yes, tab --> I[Inline tab cleanup: remove margin/width/element]
    G -- No --> J[hide true - also clears wasOpenInTab]
    H --> K[update innerWidth & mode]
    I --> K
    J --> K
    K --> L{new mode === 'tab'?}
    L -- Yes --> M[shouldShow = wasOpenInTab OR sidebarShown==='1' - wasOpenInTab already false if path J ran]
    L -- No --> N[shouldShow = false]
    M --> O{shouldShow?}
    N --> P[activated=false, sidebarShown=0]
    O -- Yes --> Q[animationDuration=0s, show, reset after 100ms]
    O -- No --> P
Loading

Reviews (4): Last reviewed commit: "fix: update sidebar activation logic to ..." | Re-trigger Greptile

Comment thread src/components/sidebar/index.js
Comment thread src/components/sidebar/style.scss Outdated
@Elitex07

Copy link
Copy Markdown
Contributor Author

@greptile review again

Comment thread src/components/sidebar/index.js
@Elitex07

Copy link
Copy Markdown
Contributor Author

@greptile review again

Comment thread src/components/sidebar/index.js
@Elitex07

Copy link
Copy Markdown
Contributor Author

@greptile review again

@Elitex07

Copy link
Copy Markdown
Contributor Author

@bajrangCoder vo thoda formatting :)

@Elitex07 Elitex07 moved this from Backlog to Ready in The Code Board - Acode Jun 15, 2026
@Elitex07 Elitex07 moved this from Ready to Done in The Code Board - Acode Jun 15, 2026
@UnschooledGamer UnschooledGamer added the CI: RUN ON-DEMAND PREVIEW RELEASES Triggers an on-demand preview build for this pull request via CI workflow. label Jun 16, 2026
@github-actions github-actions Bot removed the CI: RUN ON-DEMAND PREVIEW RELEASES Triggers an on-demand preview build for this pull request via CI workflow. label Jun 16, 2026
@github-actions

This comment has been minimized.

@github-actions

Copy link
Copy Markdown

Preview Release for this, has been built.

Click here to view that github actions build

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Sidebar Size Behaviour

3 participants