prettier-plugin-classnames icon indicating copy to clipboard operation
prettier-plugin-classnames copied to clipboard

Scroll position jumps to top of file on save when using plugin with WebStorm

Open italoalmeida0 opened this issue 5 months ago • 1 comments

Dependency information

  • prettier: 3.6.2
  • prettier-plugin-classnames: ^0.8.1
  • prettier-plugin-tailwindcss: ^0.6.13
  • WebStorm: 2025.1.3
  • OS: Windows 11
  • Node.js: v22.17.0

Prettier configuration

{
  "semi": true,
  "singleQuote": true,
  "trailingComma": "es5",
  "useTabs": false,
  "tabWidth": 2,
  "printWidth": 100,
  "bracketSpacing": true,
  "arrowParens": "always",
  "endOfLine": "lf",
  "plugins": ["prettier-plugin-tailwindcss", "prettier-plugin-classnames"]
}

Steps to reproduce

  1. Install prettier-plugin-classnames with prettier-plugin-tailwindcss in a project
  2. Configure WebStorm to format with Prettier on save (Settings > Languages & Frameworks > JavaScript > Prettier > On save)
  3. Open any JSX/TSX file with long className strings
  4. Scroll to the middle or bottom of the file
  5. Make any change and save (Ctrl+S)

The current behavior

When saving a file with "format on save" enabled in WebStorm, the editor scroll position jumps to the top of the file after formatting completes. This happens only when prettier-plugin-classnames is active - removing the plugin from the configuration resolves the scroll issue. The plugin works correctly (formats classNames), but causes this scroll position reset.

The expected behavior

The scroll position should remain at the current location after formatting, maintaining the developer's view of the code they're working on. This is the default behavior when using Prettier without this plugin or with only prettier-plugin-tailwindcss.

italoalmeida0 avatar Jul 09 '25 09:07 italoalmeida0

Hello! Thanks for reporting the issue!

Since I'm not currently using WebStorm, it may take some time to investigate the issue.

ony3000 avatar Jul 12 '25 03:07 ony3000