Skip to content

Potentially Confusing Double Template Refs #13020

@Disservin

Description

@Disservin

Vue version

3.5.13

Link to minimal reproduction

https://play.vuejs.org/#eNp9kj1PwzAQhv/KyUtbqTQDTCVFAtQBBkClo5cqvRQXx7b8ESpF+e+cnbaEqsp2vvc557nIDXs0ZlYHZHOWu8IK48GhD+aBK1EZbT00EByusTJy43GF5RQsltBCaXUFIxod3XPFVaGV8yCUCZ4gWFxMjTlLGWcTwnswkXTfeMJVnnUC9Gk6+OMsnQDyrahT8a8EaJp0R9ses2yYI4+raCdCGouzJdQ3ld6i7HWyTuU4mGc9QzZl3tFSpdjN9k4r+ptNhDkrdGWERPtuvKClOZtDSmK2kVL/vKaetwGnp37xhcX3lf7eHWKPsw+LDm2NnJ0zv7E7JMsYLz/f8ED1OaRNgiR6IFyh0zJExw57CmpL2j0u2b6kNyHUbu2WB4/KnZaKopFsE88ZvYvngdX/dG9nd2mOq5a1v7t717o=

Steps to reproduce

There are two template refs available to the input.

What is expected?

While technically being correct, the code example from the playground is probably not what the (new) user intended.

New users will probably start using useTemplateRef and may fall into the trap of defining another ref with a name which is equal to the ref on the HTML Input element. This is confusing, and I think this usage was removed from the docs as well (not sure).

It would be better if the compiler would catch this case and issue a warning for last template ref, suggesting to rename/remove it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions