Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not use submit_tag auto-disabling when disable_with is set to false #40168

Conversation

igor04
Copy link
Contributor

@igor04 igor04 commented Sep 3, 2020

Summary

If we have data: { disable_with: false } then auto-disabling is turned off, but if we set automatically_disable_submit_tag to false it changes the behaviour of disable_with in an unexpected way, so explicit usage of disalbe_with: false starts to enable auto-disabling with false as the value of a disabled button.

It looks like a more convenient way to have auto-disabling turned off if we have explicit disalbe_with: false no matter what is set in automatically_disable_submit_tag

If automatically_disable_submit_tag is set to false then disable_with
is ignored, as result in all cases where disable_with is explicitly set
to false will produce unexpected result
@rails-bot rails-bot bot added the actionview label Sep 3, 2020
@@ -897,16 +897,15 @@ def sanitize_to_id(name)
end

def set_default_disable_with(value, tag_options)
return unless ActionView::Base.automatically_disable_submit_tag
data = tag_options["data"]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
data = tag_options["data"]
data = tag_options.fetch("data", {})

This will save us from checking data && data["disable_with"] == false and also data.delete("disable_with") if data and disable_with_text ||= data["disable_with"] if data.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@KapilSachdev this broke our app. We have places where we're passing data: nil:

- data = { confirm: "sure?" } if doc.confirm?
= f.submit 'Update choice', data: data

@rails-bot
Copy link

rails-bot bot commented Dec 2, 2020

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
Thank you for your contributions.

@rails-bot rails-bot bot added the stale label Dec 2, 2020
@rails-bot rails-bot bot closed this Dec 9, 2020
@rafaelfranca rafaelfranca reopened this Dec 9, 2020
@rails-bot rails-bot bot removed the stale label Dec 9, 2020
@rafaelfranca rafaelfranca merged commit e0a362c into rails:master Dec 9, 2020
rafaelfranca added a commit that referenced this pull request Dec 9, 2020
…disable_submit_tag

Do not use submit_tag auto-disabling when disable_with is set to false
rafaelfranca added a commit that referenced this pull request Dec 9, 2020
…disable_submit_tag

Do not use submit_tag auto-disabling when disable_with is set to false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants