Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Fix jump when clicking tabs #3746

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

Merged
gregberge merged 1 commit into main from greg/rnd-8463-scroll-jumps-when-changing-tab-in-gbo
Oct 21, 2025

Conversation

@gregberge
Copy link
Contributor

@gregberge gregberge commented Oct 21, 2025

No description provided.

Copy link

linear bot commented Oct 21, 2025

Copy link

changeset-bot bot commented Oct 21, 2025

⚠️ No Changeset found

Latest commit: 23fa5e6

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes an issue where clicking on tabs causes an unwanted page jump. The solution prevents unnecessary scrolling by tracking previous hash/pathname values and only scrolling when there are actual changes. Additionally, it prevents Next.js router from auto-scrolling when tabs are clicked.

Key changes:

  • Added a usePrevious hook to track previous values of hash and pathname
  • Modified scroll behavior to only trigger when hash or pathname actually changes
  • Disabled automatic scroll behavior in the Next.js router when replacing tab URLs

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
packages/gitbook/src/components/hooks/usePrevious.ts New hook to track previous render values
packages/gitbook/src/components/hooks/useScrollPage.ts Updated scroll logic to compare previous/current values and avoid unnecessary scrolling
packages/gitbook/src/components/DocumentView/Tabs/DynamicTabs.tsx Disabled router scroll behavior when changing tabs and added scroll-margin to tab panels

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Copy link

argos-ci bot commented Oct 21, 2025
edited
Loading

The latest updates on your projects. Learn more about Argos notifications ↗︎

Build Status Details Updated (UTC)
customers-v2 (Inspect) 👍 Changes approved 1 changed Oct 21, 2025, 3:47 PM
v2-cloudflare (Inspect) ✅ No changes detected - Oct 21, 2025, 3:51 PM
v2-vercel (Inspect) 👍 Changes approved 2 changed Oct 21, 2025, 3:50 PM

@gregberge gregberge merged commit d436b04 into main Oct 21, 2025
16 checks passed
@gregberge gregberge deleted the greg/rnd-8463-scroll-jumps-when-changing-tab-in-gbo branch October 21, 2025 16:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

Copilot code review Copilot Copilot left review comments

@clairechabas clairechabas clairechabas approved these changes

@conico974 conico974 Awaiting requested review from conico974

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /