mirror of
https://github.com/discourse/discourse.git
synced 2025-06-01 04:13:53 +08:00
DEV: Normalize key modifier checks for keyboard shortcuts (#22451)
This introduces a PLATFORM_KEY_MODIFIER const that can be used both client and server side, to determine whether we should be using the Meta or Ctrl key based on whether the user is on Windows/Linux or Mac.
This commit is contained in:
@ -7,7 +7,6 @@ RSpec.describe "Chat | composer | shortcuts | channel", type: :system do
|
||||
let(:chat) { PageObjects::Pages::Chat.new }
|
||||
let(:channel_page) { PageObjects::Pages::ChatChannel.new }
|
||||
let(:thread_page) { PageObjects::Pages::ChatThread.new }
|
||||
let(:key_modifier) { RUBY_PLATFORM =~ /darwin/i ? :meta : :control }
|
||||
|
||||
before do
|
||||
chat_system_bootstrap
|
||||
|
@ -3,8 +3,6 @@
|
||||
module PageObjects
|
||||
module Pages
|
||||
class Chat < PageObjects::Pages::Base
|
||||
MODIFIER = RUBY_PLATFORM =~ /darwin/i ? :meta : :control
|
||||
|
||||
def message_creator
|
||||
@message_creator ||= PageObjects::Components::Chat::MessageCreator.new
|
||||
end
|
||||
@ -24,7 +22,7 @@ module PageObjects
|
||||
end
|
||||
|
||||
def open_new_message
|
||||
send_keys([MODIFIER, "k"])
|
||||
send_keys([PLATFORM_KEY_MODIFIER, "k"])
|
||||
find(".chat-new-message-modal")
|
||||
end
|
||||
|
||||
|
@ -8,8 +8,6 @@ module PageObjects
|
||||
|
||||
SELECTOR = ".chat-composer__wrapper"
|
||||
|
||||
MODIFIER = RUBY_PLATFORM =~ /darwin/i ? :meta : :control
|
||||
|
||||
def initialize(context)
|
||||
@context = context
|
||||
end
|
||||
@ -59,7 +57,7 @@ module PageObjects
|
||||
end
|
||||
|
||||
def emphasized_text_shortcut
|
||||
input.send_keys([MODIFIER, "i"])
|
||||
input.send_keys([PLATFORM_KEY_MODIFIER, "i"])
|
||||
end
|
||||
|
||||
def cancel_shortcut
|
||||
@ -67,11 +65,11 @@ module PageObjects
|
||||
end
|
||||
|
||||
def indented_text_shortcut
|
||||
input.send_keys([MODIFIER, "e"])
|
||||
input.send_keys([PLATFORM_KEY_MODIFIER, "e"])
|
||||
end
|
||||
|
||||
def bold_text_shortcut
|
||||
input.send_keys([MODIFIER, "b"])
|
||||
input.send_keys([PLATFORM_KEY_MODIFIER, "b"])
|
||||
end
|
||||
|
||||
def open_emoji_picker
|
||||
|
Reference in New Issue
Block a user