Skip to content

Don't show answer sorting buttons if there are none#1630

Merged
Oaphi merged 9 commits intodevelopfrom
0valt/1350
May 30, 2025
Merged

Don't show answer sorting buttons if there are none#1630
Oaphi merged 9 commits intodevelopfrom
0valt/1350

Conversation

@Oaphi
Copy link
Member

@Oaphi Oaphi commented May 16, 2025

closes #1350

Additionally, this PR:

  • removes the " Answers" header if there are no answers visible to the user;
  • ensures the N in the abovementioned header accounts for deleted answers that the user can access;
  • removes the line from the top of the title line of first-level posts (see Should a question page have a line above the title? - it made sense for me to make the change while I am at it);

Before the change:

Screenshot from 2025-05-16 17-16-11

After the change:

image

Same view for a user that can see deleted answers (the example post has 1 undeleted + 2 deleted answers -> 3 total):

image

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:

image

If there are, "Add an answer" will be shown instead:

Screenshot from 2025-05-17 12-59-26


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:

image

@Oaphi Oaphi self-assigned this May 16, 2025
@Oaphi Oaphi marked this pull request as draft May 16, 2025 14:26
@cellio
Copy link
Member

cellio commented May 16, 2025

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?

@Oaphi
Copy link
Member Author

Oaphi commented May 16, 2025

but can we do even better by combining the headings in the 0-answer case?

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.

@cellio
Copy link
Member

cellio commented May 16, 2025

but can we do even better by combining the headings in the 0-answer case?

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:

  • "N answers" heading: if 0 then omit, else show as we do now
  • Heading above answer textbox: if 0 answers then customize text, else "your answer" like we do now

@Oaphi Oaphi marked this pull request as ready for review May 17, 2025 10:13
@Oaphi Oaphi requested review from a team, cellio and trichoplax May 17, 2025 10:13

<%= render 'posts/expanded', post: @post, float_notice: false %>

<% num_answers = @children.count %>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.)

Copy link
Member Author

@Oaphi Oaphi May 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

@Oaphi Oaphi merged commit 94eabe6 into develop May 30, 2025
8 checks passed
@Oaphi Oaphi deleted the 0valt/1350 branch May 30, 2025 17:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

On question pages, don't show answer sorting buttons until there are answers

2 participants