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

Allow beatmap discussion reply editor to be closed #2020

Merged
merged 3 commits into from
Dec 18, 2017
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
25 changes: 19 additions & 6 deletions resources/assets/coffee/react/beatmap-discussions/new-reply.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,16 @@ class BeatmapDiscussions.NewReply extends React.PureComponent
div className: "#{bn}__avatar",
el UserAvatar, user: @props.currentUser, modifiers: ['full-rounded']

@renderCancelButton()

div className: "#{bn}__message-container",
el TextareaAutosize,
minRows: 3
disabled: @state.posting?
className: "#{bn}__message #{bn}__message--editor"
value: @state.message
onChange: @setMessage
onKeyDown: @handleEnter
onKeyDown: @handleKeyDown
placeholder: osu.trans 'beatmaps.discussions.reply_placeholder'
inputRef: (el) => @box = el

Expand All @@ -74,6 +76,8 @@ class BeatmapDiscussions.NewReply extends React.PureComponent
className: "#{bn}__footer"
div className: "#{bn}__actions",
div className: "#{bn}__actions-group",
@renderCancelButton()

This comment was marked as off-topic.

This comment was marked as off-topic.


if @canResolve() && !@props.discussion.resolved
@renderReplyButton
text: osu.trans('common.buttons.reply_resolve')
Expand All @@ -93,6 +97,14 @@ class BeatmapDiscussions.NewReply extends React.PureComponent
icon: 'reply'


renderCancelButton: =>
button
className: "#{bn}__action #{bn}__action--cancel"
disabled: @state.posting?
onClick: => @setState editing: false
el Icon, name: 'times'


renderPlaceholder: =>
[text, icon] =
if @props.currentUser.id?
Expand Down Expand Up @@ -137,11 +149,12 @@ class BeatmapDiscussions.NewReply extends React.PureComponent
@box?.focus()


handleEnter: (e) =>
return if e.keyCode != 13 || e.shiftKey

e.preventDefault()
@throttledPost(e)
handleKeyDown: (e) =>
if e.keyCode == 27
@setState editing: false
else if e.keyCode == 13 && !e.shiftKey
e.preventDefault()
@throttledPost(e)


post: (event) =>
Expand Down
6 changes: 6 additions & 0 deletions resources/assets/less/bem/beatmap-discussion-post.less
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,12 @@
margin: 0 5px;
font-size: @font-size--small;
}

&--cancel {
position: absolute;
top: 10px;
right: 10px;
}
}

&__actions {
Expand Down