Skip to content

Rename symbol on a HTML tag inside of JSX globally renames all tags #7458

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

Open
egamma opened this issue Mar 10, 2016 · 7 comments
Open

Rename symbol on a HTML tag inside of JSX globally renames all tags #7458

egamma opened this issue Mar 10, 2016 · 7 comments
Labels
Domain: JSX/TSX Relates to the JSX parser and emitter Experience Enhancement Noncontroversial enhancements Suggestion An idea for TypeScript VS Code Tracked There is a VS Code equivalent to this issue
Milestone

Comments

@egamma
Copy link
Member

egamma commented Mar 10, 2016

From @xirzec on March 9, 2016 22:24

  1. Open a project that uses TypeScript + JSX (with react.d.ts loaded)
  2. Put the cursor over a common HTML tag like <div>
  3. Hit F2 to rename symbol
  4. Rename the div to something else (like span)

Expected: Just the matching open/close is renamed to <span>
Actual: Every div in every JSX file is now a span and even react.d.ts has had its div attribute in the HTML tag names renamed to span

VS Code version: 0.10.10

Copied from original issue: microsoft/vscode#3937

@billti
Copy link
Member

billti commented Mar 10, 2016

This is entirely by design. The element name in a JSX expression is class/interface/function name, and renaming it renames all references to that class/interface/function, just as it would for any other symbol.

If the expectation is that we would only update the open/close tag, then that is a new feature, and not the current rename operation.

@RyanCavanaugh RyanCavanaugh added the Domain: JSX/TSX Relates to the JSX parser and emitter label Mar 10, 2016
@RyanCavanaugh RyanCavanaugh added the Suggestion An idea for TypeScript label Mar 10, 2016
@RyanCavanaugh
Copy link
Member

At a minimum we should block the operation when the tag name is sourced in IntrinsicElements

@mhegazy
Copy link
Contributor

mhegazy commented Mar 10, 2016

I think we need a general approach here. may not change anything "outside" your project. for instance any symbol from a .d.ts from a node package, or a @typings folder.

@xirzec
Copy link
Member

xirzec commented Mar 10, 2016

Yeah this is a hard problem, I think the expected behavior is a simple tag rename in the JSX markup, but that's only because of how easy it is to fall into expecting HTML language service semantics out of a JSX file.

The reason this was particularly painful in VS Code is that it edits a ton of files with a bad change and Edit -> Undo only reverted it in the currently opened document, leaving it up to the user to manually revert many unexpected edits (hope you committed your changes recently.)

@Jack-Works
Copy link
Contributor

is this fixed by #28066?

@GMaiolo
Copy link

GMaiolo commented Nov 30, 2021

Is there news about this or a workaround?

@WilsonNet
Copy link

I just discovered this bug today in the worst way possible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Domain: JSX/TSX Relates to the JSX parser and emitter Experience Enhancement Noncontroversial enhancements Suggestion An idea for TypeScript VS Code Tracked There is a VS Code equivalent to this issue
Projects
None yet
Development

No branches or pull requests

9 participants