Closed seanpdoyle closed 2 months ago
I had originally tried to add test coverage by making the following change:
diff --git a/test/inputs/rich_text_area_input_test.rb b/test/inputs/rich_text_area_input_test.rb
index 15d12a5..1fc3df7 100644
--- a/test/inputs/rich_text_area_input_test.rb
+++ b/test/inputs/rich_text_area_input_test.rb
@@ -12,4 +12,11 @@ class RichTextAreaInputTest < ActionView::TestCase
with_input_for @user, :description, :text, placeholder: 'Put in some text'
assert_select 'textarea.text[placeholder="Put in some text"]'
end
+
+ test 'input generates a rich text area for rich text area attributes from placeholder translations' do
+ store_translations(:en, simple_form: { placeholders: { user: { description: "placeholder from i18n en.simple_form.placeholders.user.description" } } }) do
+ with_input_for @user, :description, :rich_text_area
+ assert_select 'trix-editor.rich_text_are="placeholder from i18n en.simple_form.placeholders.user.description"]'
+ end
+ end
end
Unfortunately, Action Text and Trix are not available to the Simple Form test suite. Similarly, the existing coverage in test/inputs/rich_text_area_input_test.rb introduced in 3b3ab24 appears to make assertions about :text
and <textarea>
elements instead of :rich_text_area
and <trix-editor>
elements.
@seanpdoyle thank you! Yeah, I know about that rich_text_area
spec, I'll try to look into it a bit later.
Trix (the rich text editor that's rendered by Action View's form builder) has supported the
[placeholder]
attribute since at least version 0.9.0 (and continues to support it in 2.1.1.This commit enables
:placeholder
support in theSimpleForm::Inputs::RichTextAreaInput
class to transform placeholder internationalization strings intotrix-editor[placeholder]
HTML attributes.