Add preventDefaults to stop form submits on likes. Fixes #153

This commit is contained in:
Dessalines 2021-02-02 11:52:44 -05:00
parent 7d8f1a1ced
commit 398cdf682c
2 changed files with 8 additions and 4 deletions

View file

@ -882,7 +882,8 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
this.setState(this.state);
}
handleCommentUpvote(i: CommentNodeI) {
handleCommentUpvote(i: CommentNodeI, event: any) {
event.preventDefault();
let new_vote = this.state.my_vote == 1 ? 0 : 1;
if (this.state.my_vote == 1) {
@ -910,7 +911,8 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
setupTippy();
}
handleCommentDownvote(i: CommentNodeI) {
handleCommentDownvote(i: CommentNodeI, event: any) {
event.preventDefault();
let new_vote = this.state.my_vote == -1 ? 0 : -1;
if (this.state.my_vote == 1) {

View file

@ -1155,7 +1155,8 @@ export class PostListing extends Component<PostListingProps, PostListingState> {
);
}
handlePostLike(i: PostListing) {
handlePostLike(i: PostListing, event: any) {
event.preventDefault();
if (!UserService.Instance.user) {
this.context.router.history.push(`/login`);
}
@ -1187,7 +1188,8 @@ export class PostListing extends Component<PostListingProps, PostListingState> {
setupTippy();
}
handlePostDisLike(i: PostListing) {
handlePostDisLike(i: PostListing, event: any) {
event.preventDefault();
if (!UserService.Instance.user) {
this.context.router.history.push(`/login`);
}