Welcome to Codidact Meta!
Codidact Meta is the meta-discussion site for the Codidact community network and the Codidact software. Whether you have bug reports or feature requests, support questions or rule discussions that touch the whole network – this is the site for you.
Answers order is changed when we access a specific answer by its direct link
Not sure if this is a bug, or status-by-design (for now, tagged as bug just in case)
When accessing an answer by its direct link, its order (relative to all other answers) is changed.
Example: if I go to this question, the answers are displayed by Score (I guess this is the default?), with highest scores first. If I click on the sort options ("Score" or "Active"), it all works well.
But if I access that post using a direct link to a specific answer, that answer is displayed before all the others, even though it has the lowest score. That happens even if I explicitly choose to sort the answers by Score: clicking on "Score", the link changes to this, and it still shows that specific answer (which has a lower score) before the others with higher scores.
That happens only if the link contains an answer ID. Summary:
- Links to question: OK (answers displayed in correct order)
https://meta.codidact.com/posts/276161
https://meta.codidact.com/posts/276161?sort=score
- Links to specific answer: Not OK (the specific answer is displayed before the other answers, although it has a lower score)
https://meta.codidact.com/posts/276161/276162#answer-276162
https://meta.codidact.com/posts/276161/276162?sort=score
Is it intentional that the display order of answers is changed like that when we access it by an answer's direct link?
2 answers
This is by design. Sometimes, for example for the Code Golf scoreboard, we need to have a direct link to the answers. Since on questions with many answers the answers are paginated and the order is calculated "on the fly", it's not possible to say beforehand, on which page an answer would be.
Therefore we added that helper URL which forces the answer to be shown without regards to the pagination; especially as that's easier to do than doing complex (and inefficient) calculations about the page the answer is likely to be on.
To reduce confusion, we have now added a notice above the answer when it is shown out of order, like this:
I'm not sure how intentional it is, but it's a known change to fix a related bug. Until recently, if you followed a direct link to an answer that wasn't on the first page of the post, that action failed and you got redirected to the question instead. I'm not sure of all the details, but apparently doing the right thing -- jumping to that answer on page N of the question -- is hard. To make direct links useful, the solution was to move the target answer to the top and then jump to it. If there is a better way to solve this problem and link to the answer where it normally falls (without breaking existing URL routes), we're interested in learning about it. The discussion on the issue that led to this change might be useful context.
I hadn't noticed, though it makes sense now that you point it out, that this relocation happens in all cases, not just cases where there are multiple pages. I wonder if we can do this only where answer count is higher than the page limit. Determining what page an answer is on is hard, but detecting whether there are going to be multiple pages might be easier. (I should clarify that I have only a theoretical understanding of the code involved.)
0 comment threads