Skip to content

Scroll position resets if useSanityQuery is used #1366

@felixSchl

Description

@felixSchl

Version

module: 2.0.0
nuxt: 4.1.3

Nuxt configuration

  sanity: {
    projectId: process.env.NUXT_SANITY_PROJECT_ID,
    dataset: process.env.NUXT_SANITY_DATASET,
    apiVersion: process.env.NUXT_SANITY_API_VERSION || "2025-10-20",
    token: process.env.NUXT_SANITY_API_READ_TOKEN, // Only required when using a private dataset
    visualEditing: {
      token: process.env.NUXT_SANITY_API_READ_TOKEN,
      studioUrl: process.env.NUXT_SANITY_STUDIO_URL,
      stega: true,
      zIndex: 51,
    },
  },

What is expected?

Scroll position remains after HMR.

What is actually happening?

Scroll position resets every time I change my .vue file.

Steps to reproduce

Additional information

Checklist

  • I have tested with the latest Nuxt version and the issue still occurs
  • I have tested with the latest module version and the issue still occurs
  • I have searched the issue tracker and this issue hasn't been reported yet

Steps to reproduce

Use useSanityQuery. Even if result is never read, every change to the containing .vue file will lose the scroll position.

What is expected?

Scroll position remains stable.

What is actually happening?

Scroll position resets to top of page.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions