Skip to content

Commit 2bc93a1

Browse files
authored
Merge pull request rubycentral#884 from amatsuda/fix_rating
Fix a bug that clicking a star with pointer cursor sends score: 1
2 parents 714ba56 + 778a500 commit 2bc93a1

2 files changed

Lines changed: 17 additions & 11 deletions

File tree

app/assets/stylesheets/modules/ratings.css

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
text-align: center;
4444
direction: rtl;
4545
font-size: 18px;
46+
cursor: pointer;
4647

4748
* {
4849
position: absolute;
@@ -58,14 +59,21 @@
5859
}
5960
}
6061

62+
label {
63+
cursor: pointer;
64+
}
65+
6166
input {
6267
z-index: 5;
6368
cursor: pointer;
6469
opacity: 0;
70+
width: 18px;
71+
height: 18px;
6572
}
6673

6774
&.ratings-closed {
6875
color: var(--gray);
76+
cursor: default;
6977

7078
input {
7179
pointer-events: none;

app/views/shared/proposals/_rating_form.html.haml

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,23 +11,21 @@
1111
.rating-form-wrapper
1212
%ul.star-rating
1313
- (1..5).each do |score|
14-
%li.star-wrapper{class: disabled ? "ratings-closed" : nil}
15-
= f.label :score, data: {action: 'mouseenter->rating#preview mouseleave->rating#showRating'} do
16-
%span.star
17-
%i.bi.bi-star
18-
%i.bi.bi-star-fill
19-
= f.check_box :score, {class: 'star-rating-select', disabled: disabled}, score, nil
14+
%li.star-wrapper{class: disabled ? "ratings-closed" : nil, data: {action: 'mouseenter->rating#preview mouseleave->rating#showRating'}}
15+
%span.star
16+
%i.bi.bi-star
17+
%i.bi.bi-star-fill
18+
= f.check_box :score, {class: 'star-rating-select', disabled: disabled}, score, nil
2019
- if show_ratings_toggle?(proposal, rating)
2120
%li.abstain-wrapper
2221
= link_to "#", class: 'abstain', data: {action: 'click->rating#toggleCommentsAndRatings'} do
2322
%i.bi.bi-chat-dots
2423
%i.bi.bi-chat-dots-fill.hidden
2524
- if show_destroy_rating?(proposal, rating)
26-
%li.trash-wrapper
27-
= f.label :score, data: {action: 'mouseenter->rating#previewDelete mouseleave->rating#cancelPreviewDelete'} do
28-
%span.trash
29-
%i.bi.bi-trash
30-
= f.check_box :score, { class: "star-rating-select delete" }, "", nil
25+
%li.trash-wrapper{data: {action: 'mouseenter->rating#previewDelete mouseleave->rating#cancelPreviewDelete'}}
26+
%span.trash
27+
%i.bi.bi-trash
28+
= f.check_box :score, { class: "star-rating-select delete" }, "", nil
3129
#show-ratings{ class: !show_ratings?(proposal, rating) ? "hidden" : nil }
3230
.col-lg-7
3331
- if proposal.ratings.any?

0 commit comments

Comments
 (0)