useTemplateRef finds unrelated references with same name #5009
Labels
bug
Something isn't working
good reproduction ✨
This issue provides a good reproduction, we will be able to investigate it first
🔨 p3-minor-bug
Vue - Official extension or vue-tsc version
2.1.10
VSCode version
1.95.2
Vue version
3.5.12
TypeScript version
5.6.3
System Info
No response
package.json dependencies
No response
Steps to reproduce
Assume the following 2 SFC components in the project:
Component A
Component B
Notice that the elements have a
ref
with the value of"name"
.There are 2 issues:
When performing "Find All References" on any of the
"name"
string, the system finds both references, even tough they are unrelated but for the name of theref
(see image below).This is actually the worst issue: when renaming one of the strings, the other also gets renamed in the <script setup>. In the image below, this is the result of renaming the ref inside
ComponentB.vue
. BothuseTemplateRef
inComponentA.vue
andComponentB.vue
have been renamed, and onlyref="name"
inComponentB.vue
has been renamed to"name2"
(this one was actually expected and the only thing working as expected).What is expected?
When renaming a string ref inside an SFC file, only the refs inside that file get renamed.
The rest of the project should be untouched, as it is unrelated to this action.
What is actually happening?
Any
useTemplateRef
which references the same named string is renamed, throughout the project.This is and incredibly dangerous and wild behaviour.
Link to minimal reproduction
No response
Any additional comments?
No response
The text was updated successfully, but these errors were encountered: