Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add aria attribute to track toggle status of up/down votes. #1074

Merged
merged 1 commit into from
Jun 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/shared/components/comment/comment-node.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -380,11 +380,12 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
<>
<button
className={`btn btn-link btn-animate ${
this.state.my_vote == 1 ? "text-info" : "text-muted"
this.state.my_vote === 1 ? "text-info" : "text-muted"
}`}
onClick={this.handleCommentUpvote}
data-tippy-content={i18n.t("upvote")}
aria-label={i18n.t("upvote")}
aria-pressed={this.state.my_vote === 1}
>
<Icon icon="arrow-up1" classes="icon-inline" />
{showScores() &&
Expand All @@ -397,13 +398,14 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
{this.props.enableDownvotes && (
<button
className={`btn btn-link btn-animate ${
this.state.my_vote == -1
this.state.my_vote === -1
? "text-danger"
: "text-muted"
}`}
onClick={this.handleCommentDownvote}
data-tippy-content={i18n.t("downvote")}
aria-label={i18n.t("downvote")}
aria-pressed={this.state.my_vote === -1}
>
<Icon icon="arrow-down1" classes="icon-inline" />
{showScores() &&
Expand Down
12 changes: 8 additions & 4 deletions src/shared/components/post/post-listing.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -401,11 +401,12 @@ export class PostListing extends Component<PostListingProps, PostListingState> {
<div className={`vote-bar col-1 pr-0 small text-center`}>
<button
className={`btn-animate btn btn-link p-0 ${
this.state.my_vote == 1 ? "text-info" : "text-muted"
this.state.my_vote === 1 ? "text-info" : "text-muted"
}`}
onClick={this.handlePostLike}
data-tippy-content={i18n.t("upvote")}
aria-label={i18n.t("upvote")}
aria-pressed={this.state.my_vote === 1}
>
<Icon icon="arrow-up1" classes="upvote" />
</button>
Expand All @@ -422,11 +423,12 @@ export class PostListing extends Component<PostListingProps, PostListingState> {
{this.props.enableDownvotes && (
<button
className={`btn-animate btn btn-link p-0 ${
this.state.my_vote == -1 ? "text-danger" : "text-muted"
this.state.my_vote === -1 ? "text-danger" : "text-muted"
}`}
onClick={this.handlePostDisLike}
data-tippy-content={i18n.t("downvote")}
aria-label={i18n.t("downvote")}
aria-pressed={this.state.my_vote === -1}
>
<Icon icon="arrow-down1" classes="downvote" />
</button>
Expand Down Expand Up @@ -688,11 +690,12 @@ export class PostListing extends Component<PostListingProps, PostListingState> {
<div>
<button
className={`btn-animate btn py-0 px-1 ${
this.state.my_vote == 1 ? "text-info" : "text-muted"
this.state.my_vote === 1 ? "text-info" : "text-muted"
}`}
{...tippy}
onClick={this.handlePostLike}
aria-label={i18n.t("upvote")}
aria-pressed={this.state.my_vote === 1}
>
<Icon icon="arrow-up1" classes="icon-inline small" />
{showScores() && (
Expand All @@ -702,11 +705,12 @@ export class PostListing extends Component<PostListingProps, PostListingState> {
{this.props.enableDownvotes && (
<button
className={`ml-2 btn-animate btn py-0 px-1 ${
this.state.my_vote == -1 ? "text-danger" : "text-muted"
this.state.my_vote === -1 ? "text-danger" : "text-muted"
}`}
onClick={this.handlePostDisLike}
{...tippy}
aria-label={i18n.t("downvote")}
aria-pressed={this.state.my_vote === -1}
>
<Icon icon="arrow-down1" classes="icon-inline small" />
{showScores() && (
Expand Down