Steps to replicate the issue:
- Go to https://en.wikipedia.org/wiki/Wikipedia_talk:Sandbox
- Add a comment starting with an invisible element, e.g. <span style="display: none;">hidden text</span>comment --~~~~
- Preview the page. Click the comment's timestamp link.
What happens?:
Example input:
== Test == <span style="display: none;">hidden text</span>comment--[[User:Example|Example]] 10:46, 31 October 2025 (UTC)
Output:
<div class="mw-heading mw-heading2 ext-discussiontools-init-section"> <h2 id="Test" data-mw-thread-id="h-Test-20251031104600"><span data-mw-comment-start="" id="h-Test-20251031104600"></span>Test<span data-mw-comment-end="h-Test-20251031104600"></span></h2> <div class="ext-discussiontools-init-section-bar"><div class="ext-discussiontools-init-section-metadata"></div><div class="ext-discussiontools-init-section-actions"></div></div> </div> <p> <span style="display: none;"><span data-mw-comment-start="" id="c-Example-20251031104600-Test"></span>hidden text</span>comment--<span data-mw-comment-sig="c-Example-20251031104600-Test"></span><a href="/wiki/User:Example" title="User:Example">Example</a> <a href="#c-Example-20251031104600-Test" class="ext-discussiontools-init-timestamplink" title="9 hours ago">10:46, 31 October 2025 (UTC)</a><span class="ext-discussiontools-init-replylink-buttons" data-mw-thread-id="c-Example-20251031104600-Test"></span><span data-mw-comment-end="c-Example-20251031104600-Test"></span> </p>
The comment is not visibly highlighted, because DiscussionTools puts the comment's range start marker inside the invisible element. For the same reason, the comment is not scrolled into view when the link is opened in a new tab.
What should have happened instead?:
DiscussionTools should not insert markers related to comment anchor or highlighting into invisible elements.
Software version: 1.45.0-wmf.25
Other information:
The issue stems from the implementation of zh:Template:Hidden ping, which puts user page links inside <span style="display: none;">. Comment permalinks thus fail when the template is at the beginning of the comment.