Comments on Comment thread leads to "404 Not Found" error page
Parent
Comment thread leads to "404 Not Found" error page
This answer has one comment, $X\times X \cong X$. But when I attempt to click on the comment to show it, it leads to a 404 page.
Why is this?
(Update: the comment is not deleted as I had previously thought; it is accessible at https://math.codidact.com/comments/thread/11717 , and one can access it by Ctrl-clicking to open it in a new tab. The problem is that some JavaScript function in Codidact is returning "undefined" as the comment thread number and so the Codidact website makes an XHR request to https://math.codidact.com/comments/thread/undefined/content?inline=true&show_deleted_comments=0 ---the "undefined" there ought to be "11717".)
(Update 2: It seems to have something to do with math in the comment thread title---see the test comment I made to this post, titled $X × X$.)
Post
I found that the problem is with the event-listener code in line 73 of https://math.codidact.com/assets/application-ba1f9d37b09ac57d363a53b8936f4b70438bff1fbe2ae8408013ec99fc833225.js . The event-listener sets the "i" object, whose "data-thread" attribute yields the comment thread number, as the target of the "click" event. This works when one clicks on normal text (because the immediately enclosing element is then an a.js--comment-link element) but does not work when one clicks on math (because the immediately enclosing element is then an mjx-container or similar element). Hence the previous bug-report appears incorrect when it says that refreshing the page fixed the problem: in fact, the issue is still present if you click on the MathJax $+1$, but when you click elsewhere the comment expands correctly (so, probably, the user clicked on the $+1$ the first time around and then clicked elsewhere the next time). You can confirm that this is the root of the problem by using the inspector to edit (say, italicize) a part of the text in a comment title and then clicking on the italicized part; it will give a 404 error.)
(Hence, to fix the problem, change the code
async e => {
if (e.ctrlKey || e.metaKey) return;
e.preventDefault();
const i = $(e.target),
a = i.data("thread");
t(n(i), a)
}
to something like
async e => {
if (e.ctrlKey || e.metaKey) return;
e.preventDefault();
const i = $(e.target);
while (!i.classNames.contains("js--comment-link")) i=i.parentElement;
a = i.data("thread");
t(n(i), a)
}
I don't know what code this corresponds to in the non-minified JS, though.)

3 comment threads