Steps to replicate the issue:
- Open https://en.wikipedia.org/w/index.php?title=Saint_Joseph&action=edit and confirm it has {{DEFAULTSORT:Joseph, Saint}}
- Switch to VisualEditor
- Scroll to bottom or open Page options -> Options
What happens?:
Nonexistent template "DEFAULTSORT:Joseph, Saint" appears at the bottom. In Options, "Sort this page by default as" is set to Saint_Joseph. If you set it something else, apply changes, and switch to source editing, an extra {{DEFAULTSORT:...}} is appended at the end despite the extant tag.
What should have happened instead?:
{{DEFAULTSORT:...}} is not recognized as a template but in "Sort this page by default as". Changing it in the dialog modifies the existing tag rather than add a new one.
Other information:
Happening on some pages but not on others. In the first ten results for :insource:"defaultsort", the bug is reproducible on
but not on
Also reproducible while creating a new page with just {{DEFAULTSORT:...}} (or with nothing, so switching to VE, adding one in the dialog, and switching back keeps adding new tags).