mirror of
https://github.com/heartcombo/simple_form.git
synced 2022-11-09 12:19:26 -05:00
Fix 'aria-required' field generated by prompt
This commit is contained in:
parent
fe9e69945e
commit
f9f6252238
2 changed files with 7 additions and 1 deletions
|
@ -41,7 +41,7 @@ module SimpleForm
|
|||
end
|
||||
|
||||
def has_required?
|
||||
super && (input_options[:include_blank] || input_options[:prompt] || multiple?)
|
||||
super && (input_options[:include_blank] || input_options[:prompt].present? || multiple?)
|
||||
end
|
||||
|
||||
# Check if :include_blank must be included by default.
|
||||
|
|
|
@ -284,6 +284,12 @@ class CollectionSelectInputTest < ActionView::TestCase
|
|||
assert_select 'select[required]'
|
||||
end
|
||||
|
||||
test "collection input generated aria-label should contain 'true'" do
|
||||
with_input_for @user, :age, :select, collection: 18..30, prompt: "Please select foo"
|
||||
assert_select 'select.required'
|
||||
assert_select 'select[aria-required=true]'
|
||||
end
|
||||
|
||||
test 'collection input with select type does not generate required html attribute without blank option' do
|
||||
with_input_for @user, :name, :select, include_blank: false, collection: %w[Jose Carlos]
|
||||
assert_select 'select.required'
|
||||
|
|
Loading…
Reference in a new issue