Don't show answer sorting buttons if there are none#1630
Conversation
|
I agree that the spacing looks weird without the intervening buttons. More space would be good, but can we do even better by combining the headings in the 0-answer case? "Be the first to answer", "0 answers - add yours", something like that? |
…ter_culture quirk breaking system tests)
Yeah, I like the idea, no need to waste space in this case. That said, do note that I opted to remove the buttons if there's only one answer as well - meaning that we should be careful with when we merge the headers. |
Oh, I missed the single-answer case. Yeah, that changes things a little. The spacing is only a problem when there are 0 answers and those two headings are right next to each other. So I guess the logic I'm proposing (if this is too complicated we should punt) is:
|
causes noticeable layout shift on deleted posts
|
|
||
| <%= render 'posts/expanded', post: @post, float_notice: false %> | ||
|
|
||
| <% num_answers = @children.count %> |
There was a problem hiding this comment.
Info: does this count all answers or only answers the viewing user can see? (The PR shows an example for people who can see deleted answers; just want to make sure we're doing the right thing for people who can't.)
There was a problem hiding this comment.
Only those that the user can see, yes - @children is a local variable set by the controller (method show on the posts controller) that is assigned the correctly filtered collection (the same one is currently used to display the list of answers itself)
closes #1350
Additionally, this PR:
Nin the abovementioned header accounts for deleted answers that the user can access;Before the change:
After the change:
Same view for a user that can see deleted answers (the example post has 1 undeleted + 2 deleted answers -> 3 total):
The PR also replaces (as per discussion below) the "your answer" static header with a dynamic one. If there are no answers (that are visible to the user), "Be the first to answer" will be shown:
If there are, "Add an answer" will be shown instead:
Regarding removal of the line from the top of the title line, here is how a first-level post will look like with the change: