Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion gem/lib/ruby_ui/select/select_value.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ def initialize(placeholder: nil, **attrs)

def view_template(&block)
span(**attrs) do
block ? block.call : @placeholder
value = block ? block.call : @placeholder
value || @placeholder
end
end

Expand Down
10 changes: 10 additions & 0 deletions gem/test/ruby_ui/select_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,14 @@ def test_render_with_all_items
assert_match(/John/, output)
assert_match('name="NAME"', output)
end

def test_select_value_renders_placeholder_when_block_returns_nil
output = phlex do
RubyUI.SelectValue(placeholder: "Placeholder") do
nil
end
end

assert_match(/Placeholder/, output)
end
end