Skip to content

fix: persist expanded text state of an item with query params#3060

Draft
Soxasora wants to merge 3 commits into
stackernews:masterfrom
Soxasora:fix/persist-full-item-text
Draft

fix: persist expanded text state of an item with query params#3060
Soxasora wants to merge 3 commits into
stackernews:masterfrom
Soxasora:fix/persist-full-item-text

Conversation

@Soxasora

@Soxasora Soxasora commented Jun 10, 2026

Copy link
Copy Markdown
Member

Description

Fixes #2818

After clicking show full text we now persist the expanded state of an item with full=true in the query params.
Coming back to an item with the full query param will present the item already expanded. Solves scroll restoration in long posts.

Screenshots

full-text.mp4

Additional Context

The nprogress loading bar appears when clicking show full text because we're doing a router action.

Checklist

Are your changes backward compatible? Please answer below:

Yes

On a scale of 1-10 how well and how have you QA'd this change and any features it might affect? Please answer below:

8

Did you use AI for this? If so, how much did it assist you?

No


Note

Low Risk
Low-risk UI state change using shallow routing; may trigger the nprogress bar on expand as noted in the PR.

Overview
Expanded post text now survives navigation and reloads via a full=true query parameter instead of living only in component state.

useOverflow initializes show from router.query.full, and clicking show full text performs a shallow router.replace that merges full: true into the current query while still calling setShow(true). Hash-based expansion is unchanged in behavior but only forces show to true (it no longer collapses expanded text when the URL has no hash).

Reviewed by Cursor Bugbot for commit 8902b1d. Bugbot is set up for automated code reviews on this repo. Configure here.

clicking `show full text` will save the `full`
state to the query params.

coming back to an item page with the
`full` query param will now show the full text
on first load.
@Soxasora Soxasora changed the title persist show full text state of an item to query params fix: persist expanded text state of an item with query params Jun 10, 2026

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 8902b1d. Configure here.

Comment thread components/text.js Outdated
Comment thread components/text.js Outdated
@Soxasora

Soxasora commented Jun 10, 2026

Copy link
Copy Markdown
Member Author

The nprogress loading bar appears when clicking show full text because we're doing a router action.

This is an easy fix: shouldShowProgressBar in _app.js could check the new path against the current path, both void of their query params, instead of also comparing query params.

@Soxasora Soxasora marked this pull request as draft June 10, 2026 17:13
Soxasora added 2 commits June 11, 2026 00:51
uses `useSyncExternalStore` to render the expanded
state from `sessionStorage` during the first render.

coming back to an item page with the `full` query
param will show the full text on first load.
… first render

`full` query param removed as unused
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

on browser back nav, long posts that have been opened are truncated, losing scroll position

1 participant