Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[1.x] preserveScroll should be true on initial page visit #1360

Merged
merged 4 commits into from
Sep 18, 2024

Conversation

addgod
Copy link
Contributor

@addgod addgod commented Dec 14, 2022

Preserve scroll should be true on initial page visit to mimic normal browser behavior. If a user has scrolled down the page, and then reloads, the page should stay where it is, so we cannot scroll to top, ergo we must preserve scroll.

Preserve scroll should be true on initial page visit to mimic normal browser behavior. If a user has scrolled down the page, and then reloads, the page should stay where it is, so we cannot scroll to top, ergo we must preserve scroll.
If a preserve scroll is set to true in setPage restore the scroll position.
Just fixing a typing coding.
@saas786
Copy link

saas786 commented Mar 23, 2023

Upon the initial page load, if my URL has #some-element-id, it scrolls down to that specific element. After a short delay, it scrolls back to the top (or saved scroll position), which is an unusual behavior.

Using preserveScroll: true stops the scroll down to the element and back to the top.

Ideally, it should either not scroll down to #some-element-id, or if it does, it should not scroll back to the top or the previously saved scroll position. Since it is the first page load, on subsequent requests using InertiaJS Link, it can continue to behave the same way.

@pedroborges pedroborges added the core Related to the core Inertia library label Sep 13, 2024
@pedroborges
Copy link
Collaborator

Related: #1782

@pedroborges pedroborges changed the title Preserve scroll should be true on initial page visit. [1.x] preserveScroll should be true on initial page visit Sep 13, 2024
Copy link
Collaborator

@pedroborges pedroborges left a comment

Choose a reason for hiding this comment

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

Thanks @addgod!

Copy link
Contributor

@joetannenbaum joetannenbaum left a comment

Choose a reason for hiding this comment

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

Looks good, thank you!

@pedroborges pedroborges merged commit d32a252 into inertiajs:master Sep 18, 2024
5 checks passed
pedroborges added a commit to olragon/inertia that referenced this pull request Sep 24, 2024
* master: (95 commits)
  [1.x] Fix props reactivity (inertiajs#1969)
  [1.x] useForm wrongly overwrites default values ​​after successful submission (inertiajs#1935)
  Update changelog
  [1.x] Fix `resetScrollPositions` and `restoreScrollPositions` router methods (inertiajs#1980)
  [1.x] Fix [scroll-region] on html element with overflow-scroll (inertiajs#1782)
  [1.x] Fix useForm re-renders by memoizing functions in React (inertiajs#1607)
  [1.x] Fix "DataCloneError: <Object> could not be cloned" (inertiajs#1967)
  [1.x] preserveScroll should be true on initial page visit (inertiajs#1360)
  Fix type augmentation (inertiajs#1958)
  [1.x] Fix doubling hash in React StrictMode (inertiajs#1728)
  [1.x] Add SSR support for Svelte 5 (inertiajs#1970)
  [1.x] Fix <Render /> component to respect "preserveState" (inertiajs#1943)
  [1.x] Fix 'received an unexpected slot "default"' warning (inertiajs#1941)
  QA: Add @types/lodash to fix svelte-check
  QA: Update reactive if statement
  Review useForm types
  QA: Move the if server up
  QA: Revert tsconfig change
  QA: Remove plural
  QA: Remove unused props type + add extra types just in case
  ...

# Conflicts:
#	packages/react/src/index.ts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Related to the core Inertia library
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants