Skip to content

Commit 10328b9

Browse files
authored
Merge pull request #6183 from solidusio/backport/v4.5/pr-6174
[v4.5] Fix ui/forms/input component for tag: :textarea
2 parents 2bd7779 + ba1225d commit 10328b9

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

admin/app/components/solidus_admin/ui/forms/input/component.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,8 @@ def initialize(tag: :input, size: :m, error: nil, **attributes)
9191
def call
9292
if @tag == :select && @attributes[:choices]
9393
with_content options_for_select(@attributes.delete(:choices), @attributes.delete(:value))
94+
elsif @tag == :textarea && @attributes[:value]
95+
with_content @attributes.delete(:value)
9496
end
9597

9698
build_tag

admin/spec/components/solidus_admin/ui/forms/input/component_spec.rb

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,34 @@
4141
expect(page).to have_css("input[type='date'][name='name'][value='2020-01-01']")
4242
end
4343
end
44+
45+
describe "with `tag: :textarea`" do
46+
let(:element) { page.find("textarea") }
47+
48+
context "with value passed" do
49+
let(:component) { described_class.new(tag: :textarea, name: "name", value: "Text inside a textarea") }
50+
51+
it "renders textarea with value" do
52+
render_inline(component)
53+
54+
aggregate_failures do
55+
expect(element).to have_content("Text inside a textarea")
56+
expect(element.value).to eq("Text inside a textarea")
57+
end
58+
end
59+
end
60+
61+
context "without value passed" do
62+
let(:component) { described_class.new(tag: :textarea, name: "name") }
63+
64+
it "renders textarea" do
65+
render_inline(component)
66+
67+
aggregate_failures do
68+
expect(element.text).to be_blank
69+
expect(element.value).to be_blank
70+
end
71+
end
72+
end
73+
end
4474
end

0 commit comments

Comments
 (0)