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

Added ability to submit messages with cmd+Enter (#328). #335

Merged
merged 7 commits into from Mar 21, 2022

Conversation

jasonplatts
Copy link
Contributor

@jasonplatts jasonplatts commented Mar 17, 2022

Pull request checklist

  • Your code contains tests relevant for code you modified
  • You have linted and tested the project with bin/check

Copy link
Owner

@joemasilotti joemasilotti left a 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"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// 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') {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
cmdEnterSubmit(event) {
submit(event) {

@@ -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"} %>
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<%= 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.

@joemasilotti
Copy link
Owner

Looks great! Thanks for the contribution.

@joemasilotti joemasilotti merged commit 78c2c01 into joemasilotti:main Mar 21, 2022
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants