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
Added ability to submit messages with cmd+Enter (#328). #335
Added ability to submit messages with cmd+Enter (#328). #335
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made some code formatting suggestions but other than that this looks great to me!
| @@ -0,0 +1,11 @@ | |||
| import { Controller } from "@hotwired/stimulus" | |||
|
|
|||
| // Connects to data-controller="form" | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| // Connects to data-controller="form" |
| // Connects to data-controller="form" | ||
| export default class extends Controller { | ||
| cmdEnterSubmit(event) { | ||
| if ((event.ctrlKey == true || event.metaKey == true) && event.code == 'Enter') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| if ((event.ctrlKey == true || event.metaKey == true) && event.code == 'Enter') { | |
| if ((event.ctrlKey == true || event.metaKey == true) && event.code == "Enter") { |
|
|
||
| // Connects to data-controller="form" | ||
| export default class extends Controller { | ||
| cmdEnterSubmit(event) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| cmdEnterSubmit(event) { | |
| submit(event) { |
app/views/messages/_form.html.erb
Outdated
| @@ -1,6 +1,6 @@ | |||
| <div class="border border-gray-300 sm:rounded-lg shadow-sm overflow-hidden focus-within:border-gray-500 focus-within:ring-1 focus-within:ring-gray-500"> | |||
| <%= form.label :body, t(".help"), class: "sr-only" %> | |||
| <%= form.text_area :body, rows: 4, placeholder: t(".placeholder"), class: "block w-full py-3 border-0 sm:rounded-lg sm:rounded-b-none resize-y focus:ring-0 sm:text-sm" %> | |||
| <%= form.text_area :body, rows: 4, placeholder: t(".placeholder"), class: "block w-full py-3 border-0 sm:rounded-lg sm:rounded-b-none resize-y focus:ring-0 sm:text-sm", data: {action: "keydown->form#cmdEnterSubmit"} %> | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| <%= form.text_area :body, rows: 4, placeholder: t(".placeholder"), class: "block w-full py-3 border-0 sm:rounded-lg sm:rounded-b-none resize-y focus:ring-0 sm:text-sm", data: {action: "keydown->form#cmdEnterSubmit"} %> | |
| <%= form.text_area :body, rows: 4, placeholder: t(".placeholder"), data: {action: "keydown->form#cmdEnterSubmit"}, class: "block w-full py-3 border-0 sm:rounded-lg sm:rounded-b-none resize-y focus:ring-0 sm:text-sm" %> |
Just because class can grow so I like to leave it at the end.
…age-keyboard-submit
|
Looks great! Thanks for the contribution. |
Pull request checklist
bin/check