Skip to content

Commit 938b897

Browse files
committed
ensure the first flag reason is always selected & that the flag can be sent with kbd only
1 parent f435cd5 commit 938b897

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

app/views/posts/_flag_modal.html.erb

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
user : User that will flag the post
77
"%>
88

9-
<div class="post--action-dialog js-flag-box">
9+
<%= form_tag new_flag_path, method: :post, class: 'post--action-dialog js-flag-box' do %>
1010
<div class="widget">
1111
<div class="widget--header">Why does this post require attention from curators or moderators?</div>
1212
<% if user&.active_flags_on?(post) %>
@@ -27,7 +27,7 @@
2727
</div>
2828
<% end %>
2929
<% unless post.locked? %>
30-
<% PostFlagType.where(post_type_id: [post.post_type.id, nil]).where(active: 1).each do |reason| %>
30+
<% PostFlagType.where(post_type_id: [post.post_type.id, nil]).where(active: 1).each_with_index do |reason, idx| %>
3131
<div class="widget--body">
3232
<div class="grid">
3333
<div class="grid--cell">
@@ -36,6 +36,7 @@
3636
name="flag-reason"
3737
value="<%= reason.id %>"
3838
id="flag-reason-<%= reason.id %>_<%= post.id %>"
39+
<%= 'checked' if idx.zero? %>
3940
data-requires-details="<%= reason.requires_details %>"
4041
data-response-type="<%= reason.name == "needs author's attention" ? 'comment' : nil %>" />
4142
</div>
@@ -109,10 +110,10 @@
109110
</div>
110111
<div class="widget--footer">
111112
<button class="flag-link button is-filled is-muted"
112-
data-post-type="<%= post.question? ? 'Question' : 'Answer' %>"
113-
data-post-id="<%= post.id %>">
113+
data-post-type="<%= post.question? ? 'Question' : 'Answer' %>"
114+
data-post-id="<%= post.id %>">
114115
Flag for attention
115116
</button>
116117
</div>
117118
</div>
118-
</div>
119+
<% end %>

0 commit comments

Comments
 (0)