1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Merge pull request #40168 from igor04/disable_with_and_automatically_disable_submit_tag

Do not use submit_tag auto-disabling when disable_with is set to false
This commit is contained in:
Rafael França 2020-12-09 13:38:44 -05:00 committed by GitHub
commit e0a362c138
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 4 deletions

View file

@ -934,16 +934,15 @@ module ActionView
end
def set_default_disable_with(value, tag_options)
return unless ActionView::Base.automatically_disable_submit_tag
data = tag_options["data"]
unless tag_options["data-disable-with"] == false || (data && data["disable_with"] == false)
if tag_options["data-disable-with"] == false || (data && data["disable_with"] == false)
data.delete("disable_with") if data
elsif ActionView::Base.automatically_disable_submit_tag
disable_with_text = tag_options["data-disable-with"]
disable_with_text ||= data["disable_with"] if data
disable_with_text ||= value.to_s.clone
tag_options.deep_merge!("data" => { "disable_with" => disable_with_text })
else
data.delete("disable_with") if data
end
tag_options.delete("data-disable-with")

View file

@ -562,6 +562,16 @@ class FormTagHelperTest < ActionView::TestCase
ActionView::Base.automatically_disable_submit_tag = true
end
def test_empty_submit_tag_with_opt_out_and_explicit_disabling
ActionView::Base.automatically_disable_submit_tag = false
assert_dom_equal(
%(<input name='commit' type="submit" value="Save" />),
submit_tag("Save", data: { disable_with: false })
)
ensure
ActionView::Base.automatically_disable_submit_tag = true
end
def test_submit_tag_having_data_disable_with_string
assert_dom_equal(
%(<input data-disable-with="Processing..." data-confirm="Are you sure?" name='commit' type="submit" value="Save" />),