Skip to content

A platform for community discussion. Free, open, simple.

FIX: tabbing out of the markdown editor (#33940)

Renato Atilio22c3240f17a1
diff --git a/app/assets/javascripts/discourse/app/lib/textarea-text-manipulation.js b/app/assets/javascripts/discourse/app/lib/textarea-text-manipulation.js
index 4bf58fad654..0a661500e63 100644
--- a/app/assets/javascripts/discourse/app/lib/textarea-text-manipulation.js
+++ b/app/assets/javascripts/discourse/app/lib/textarea-text-manipulation.js
@@ -727,9 +727,9 @@ export default class TextareaTextManipulation {
if (newValue.trim() !== "") {
this.replaceText(value, newValue, { skipNewSelection: true });
this.selectText(this.value.indexOf(newValue), newValue.length);
- }
- return true;
+ return true;
+ }
}
@bind
diff --git a/spec/system/composer_spec.rb b/spec/system/composer_spec.rb
index 5c417f99428..80db6b87b4d 100644
--- a/spec/system/composer_spec.rb
+++ b/spec/system/composer_spec.rb
@@ -146,4 +146,21 @@ describe "Composer", type: :system do
end
end
end
+
+ it "focuses the reply button when tabbing out of both editor modes" do
+ page.visit "/new-topic"
+ expect(composer).to be_opened
+ composer.focus
+
+ page.send_keys(:tab)
+
+ expect(composer.reply_button_focused?).to eq(true)
+
+ composer.toggle_rich_editor
+ composer.focus
+
+ page.send_keys(:tab)
+
+ expect(composer.reply_button_focused?).to eq(true)
+ end
end
diff --git a/spec/system/page_objects/components/composer.rb b/spec/system/page_objects/components/composer.rb
index 5018e8eb712..6f7c6606837 100644
--- a/spec/system/page_objects/components/composer.rb
+++ b/spec/system/page_objects/components/composer.rb
@@ -105,6 +105,10 @@ module PageObjects
self
end
+ def reply_button_focused?
+ page.has_css?("#{COMPOSER_ID} .btn-primary:focus")
+ end
+
def create
find("#{COMPOSER_ID} .btn-primary").click
end