UX: adds chat send shortcut user preference (#30473)

Users can now decide if they want to send a message on:
- <kbd>enter</kbd>
- <kbd>meta + enter</kbd>

If you choose <kbd>meta + enter</kbd>, <kbd>enter</kbd> will add a
linebreak.

<img width="192" alt="Screenshot 2025-01-21 at 12 57 48"
src="https://github.com/user-attachments/assets/abfd6f8b-83b3-4e6f-be67-8f63d536ca8a"
/>
This commit is contained in:
Joffrey JAFFEUX
2025-01-22 13:17:45 +01:00
committed by GitHub
parent a66e5ff728
commit 2cff8c82e3
13 changed files with 195 additions and 10 deletions

View File

@ -104,6 +104,74 @@ RSpec.describe "Chat composer", type: :system do
expect(channel_page.composer.value).to eq("bb")
end
context "when user preference is set to send on enter" do
before { current_user.user_option.update!(chat_send_shortcut: 0) }
context "when pressing enter" do
it "sends the message" do
chat_page.visit_channel(channel_1)
channel_page.composer.fill_in(with: "testenter").enter_shortcut
expect(channel_page.messages).to have_message(text: "testenter")
end
end
context "when pressing shift + enter" do
it "adds a linebreak" do
chat_page.visit_channel(channel_1)
channel_page.composer.fill_in(with: "testenter").shift_enter_shortcut
expect(channel_page.composer.value).to eq("testenter\n")
end
end
context "when pressing meta + enter" do
it "sends the message" do
chat_page.visit_channel(channel_1)
channel_page.composer.fill_in(with: "testenter").meta_enter_shortcut
expect(channel_page.messages).to have_message(text: "testenter")
end
end
end
context "when user preference is set to send on meta + enter" do
before { current_user.user_option.update!(chat_send_shortcut: 1) }
context "when pressing enter" do
it "adds a linebreak" do
chat_page.visit_channel(channel_1)
channel_page.composer.fill_in(with: "testenter").enter_shortcut
expect(channel_page.composer.value).to eq("testenter\n")
end
end
context "when pressing shift + enter" do
it "adds a linebreak" do
chat_page.visit_channel(channel_1)
channel_page.composer.fill_in(with: "testenter").shift_enter_shortcut
expect(channel_page.composer.value).to eq("testenter\n")
end
end
context "when pressing meta + enter" do
it "sends the message" do
chat_page.visit_channel(channel_1)
channel_page.composer.fill_in(with: "testenter").meta_enter_shortcut
expect(channel_page.messages).to have_message(text: "testenter")
end
end
end
end
context "when editing a message with no length" do