Skip to content
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

Renaming a component doesn't change references #180898

Closed
luabud opened this issue Apr 25, 2023 · 2 comments
Closed

Renaming a component doesn't change references #180898

luabud opened this issue Apr 25, 2023 · 2 comments
Assignees
Labels
*as-designed Described behavior is as designed

Comments

@luabud
Copy link
Member

luabud commented Apr 25, 2023

Testing #180769

I have two files open, one called "MyComponent2.tsx" with the following content:

import React from 'react';

function MyComponent2() {
        
  return (
    <div>
      <header>
        <nav>
          <ul>
            <li><a href="/">Home</a></li>
            <li><a href="/about">About</a></li>
            <li><a href="/contact">Contact</a></li>
          </ul>
        </nav>
      </header>
      <main>
        <h1>Welcome to My Website!</h1>
        <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam hendrerit ipsum eu tortor bibendum fringilla.</p>
        <p>Maecenas ut semper dolor. Praesent finibus arcu at augue convallis, ac vestibulum dui luctus.</p>
      </main>
      <footer>
        <p>&copy; 2023 My Company. All rights reserved.</p>
      </footer>
    </div>
  );
}

export default MyComponent2;

And then I have another one called "App.tsx"

import React from 'react';
import MyComponent2 from './MyComponent2';

function App() {
  return (
    <div>
      <p>My App</p>
      <MyComponent2></MyComponent2> 
    </div>
  );
}

export default App;

Renaming MyComponent2 on line 8 in the App.tsx file edits both tags correctly, but it doesn't rename the component itself. If I rename the symbol on line 2, it updates the tags correctly:

linkededitingbug3

I also noticed that if I only have <MyComponent2 /> on line 8 instead of the opening and closing tags, and I try to rename it, it seems to fail silently. Happy to file a separate bug if it'd be helpful:

linkededitingbug4

@luabud luabud changed the title Linked editing doesn't change referenced component name Renaming a component doesn't change references Apr 25, 2023
@mjbvz
Copy link
Collaborator

mjbvz commented Apr 25, 2023

When you're on a tag, both linked editing and F2 (post #159534) only rename the matching tag. They don't rename all references to the tag. For that you can run F2 on the component itself

This behavior matches how linked editing and F2 work in html files

@mjbvz mjbvz closed this as completed Apr 25, 2023
@mjbvz mjbvz added the *as-designed Described behavior is as designed label Apr 25, 2023
@luabud
Copy link
Member Author

luabud commented Apr 26, 2023

@mjbvz That's fair, although I didn't expect rename to silently fail as you can see on the last GIF. At least the component itself should be renamed, no?

@github-actions github-actions bot locked and limited conversation to collaborators Jun 10, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
*as-designed Described behavior is as designed
Projects
None yet
Development

No branches or pull requests

2 participants