Skip to content

Conversation

danielroe
Copy link
Member

🔗 Linked issue

resolves #32620

📚 Description

my mistake - we applied hash router scroll behaviour to all links - this updates it with a better name to help reduce likelihood of this happening again.

@danielroe danielroe requested a review from DamianGlowala July 15, 2025 13:45
Copy link

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@danielroe danielroe changed the title fix(nuxt): only use scrollBehaviorType for has scrolling fix(nuxt): only use scrollBehaviorType for hash scrolling Jul 15, 2025
Copy link

coderabbitai bot commented Jul 15, 2025

Walkthrough

The changes involve renaming variables and function parameters related to scroll behaviour in the router options code. The variable and parameter previously named behavior and defaultBehavior were renamed to hashScrollBehaviour and defaultHashScrollBehaviour, respectively, to clarify that they specifically refer to hash-based scrolling. The returned scroll position object for hash navigation now explicitly uses the behavior: hashScrollBehaviour property. No changes were made to the control flow or logic; only naming conventions and property explicitness were updated.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e35e1cc and 5d68621.

📒 Files selected for processing (1)
  • packages/nuxt/src/pages/runtime/router.options.ts (4 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
**/*.{ts,tsx}

Instructions used from:

Sources:
📄 CodeRabbit Inference Engine

  • .github/copilot-instructions.md
**/*.{ts,tsx,vue}

Instructions used from:

Sources:
📄 CodeRabbit Inference Engine

  • .github/copilot-instructions.md
🧠 Learnings (1)
packages/nuxt/src/pages/runtime/router.options.ts (3)
Learnt from: CR
PR: nuxt/nuxt#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-30T13:48:28.134Z
Learning: Applies to **/*.{ts,tsx,vue} : Use clear, descriptive variable and function names
Learnt from: huang-julien
PR: nuxt/nuxt#29366
File: packages/nuxt/src/app/components/nuxt-root.vue:16-19
Timestamp: 2024-12-12T12:36:34.871Z
Learning: In `packages/nuxt/src/app/components/nuxt-root.vue`, when optimizing bundle size by conditionally importing components based on route metadata, prefer using inline conditional imports like:

```js
const IsolatedPage = route?.meta?.isolate ? defineAsyncComponent(() => import('#build/isolated-page.mjs')) : null
```

instead of wrapping the import in a computed property or importing the component unconditionally.
Learnt from: TheAlexLichter
PR: nuxt/nuxt#31812
File: packages/nuxt/src/components/plugins/islands-transform.ts:202-202
Timestamp: 2025-04-18T18:33:41.753Z
Learning: In Nuxt, using `rolldownVersion` (not `rollupVersion`) is intentional when detecting if rolldown-vite is being used, even though TypeScript may show an error because the property isn't in standard type definitions yet.
🧬 Code Graph Analysis (1)
packages/nuxt/src/pages/runtime/router.options.ts (1)
packages/nuxt/src/app/composables/router.ts (1)
  • useRouter (15-17)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: code
  • GitHub Check: build
  • GitHub Check: codeql (actions)
  • GitHub Check: codeql (javascript-typescript)
🔇 Additional comments (6)
packages/nuxt/src/pages/runtime/router.options.ts (6)

16-16: Excellent naming improvement for clarity.

The variable name hashScrollBehaviour is much more descriptive than the previous behavior, making it clear this value specifically applies to hash-based scroll navigation. This aligns well with the PR objective to reduce the likelihood of mistakenly applying this to all links.


24-24: Consistent usage of renamed variable.

The explicit behavior: hashScrollBehaviour property in the returned object is correct and maintains consistency with the variable renaming. This makes the code more readable by explicitly showing that hash scroll behaviour is being applied.


38-38: Proper parameter passing with renamed variable.

The function call correctly passes the renamed hashScrollBehaviour variable to _calculatePosition, maintaining consistency throughout the codebase.


43-43: Consistent parameter passing in async context.

The renamed variable is correctly passed to _calculatePosition within the requestAnimationFrame callback, maintaining consistency with the previous change.


65-65: Improved parameter naming for better code documentation.

The parameter name defaultHashScrollBehaviour is significantly more descriptive than defaultBehavior, clearly indicating this parameter specifically handles hash-based scroll behaviour defaults. This follows the coding guideline for clear, descriptive function parameter names.


80-80: Correct usage of renamed parameter with proper logic.

The conditional logic isPageNavigation ? defaultHashScrollBehaviour : 'instant' correctly uses the renamed parameter and maintains the intended behaviour - only applying the configured scroll behaviour for page navigation, otherwise using 'instant'. This aligns perfectly with the PR objective to ensure scrollBehaviorType is only used when scrolling is applicable.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/default-hash

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai auto-generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

pkg-pr-new bot commented Jul 15, 2025

Open in StackBlitz

@nuxt/kit

npm i https://pkg.pr.new/@nuxt/kit@32622

nuxt

npm i https://pkg.pr.new/nuxt@32622

@nuxt/rspack-builder

npm i https://pkg.pr.new/@nuxt/rspack-builder@32622

@nuxt/schema

npm i https://pkg.pr.new/@nuxt/schema@32622

@nuxt/vite-builder

npm i https://pkg.pr.new/@nuxt/vite-builder@32622

@nuxt/webpack-builder

npm i https://pkg.pr.new/@nuxt/webpack-builder@32622

commit: 5d68621

Copy link

codspeed-hq bot commented Jul 15, 2025

CodSpeed Performance Report

Merging #32622 will not alter performance

Comparing fix/default-hash (5d68621) with main (e35e1cc)

Summary

✅ 10 untouched benchmarks

@danielroe danielroe merged commit 97832ab into main Jul 15, 2025
48 checks passed
@danielroe danielroe deleted the fix/default-hash branch July 15, 2025 15:19
@github-actions github-actions bot mentioned this pull request Jul 15, 2025
This was referenced Jul 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

v3.17.7 Router: scrollBehaviorType: 'smooth' always scroll to top smoothly
1 participant