Integrate :rich_text_area with placeholders#1842
Merged
nashby merged 1 commit intoheartcombo:mainfrom Jun 24, 2024
Merged
Conversation
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 the `SimpleForm::Inputs::RichTextAreaInput` class to transform placeholder internationalization strings into `trix-editor[placeholder]` HTML attributes. [0.9.0]: https://github.com/basecamp/trix/tree/0.9.0?tab=readme-ov-file#creating-an-editor [2.1.1]: https://github.com/basecamp/trix/tree/v2.1.1?tab=readme-ov-file#creating-an-editor
Contributor
Author
|
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
endUnfortunately, 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 |
Collaborator
|
@seanpdoyle thank you! Yeah, I know about that |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back 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
:placeholdersupport in theSimpleForm::Inputs::RichTextAreaInputclass to transform placeholder internationalization strings intotrix-editor[placeholder]HTML attributes.