diff options
author | Patrik Bóna <patrik.bona@mrhead.sk> | 2017-12-14 10:14:24 +0100 |
---|---|---|
committer | Patrik Bóna <patrik.bona@mrhead.sk> | 2018-09-27 10:59:56 +0200 |
commit | 8e07711d65a10be697020cc775e966bc2df87b7e (patch) | |
tree | 941719efc9bd4d13823de84f290e152727e2f877 /actionview/app/assets | |
parent | 8541394e71e961906daaea5961276892278c8a91 (diff) | |
download | rails-8e07711d65a10be697020cc775e966bc2df87b7e.tar.gz rails-8e07711d65a10be697020cc775e966bc2df87b7e.tar.bz2 rails-8e07711d65a10be697020cc775e966bc2df87b7e.zip |
Do not enable disabled elements for XHR redirects
Fixes #29473.
Diffstat (limited to 'actionview/app/assets')
-rw-r--r-- | actionview/app/assets/javascripts/rails-ujs/features/disable.coffee | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/actionview/app/assets/javascripts/rails-ujs/features/disable.coffee b/actionview/app/assets/javascripts/rails-ujs/features/disable.coffee index 90aa3bdf0e..a8c692ee62 100644 --- a/actionview/app/assets/javascripts/rails-ujs/features/disable.coffee +++ b/actionview/app/assets/javascripts/rails-ujs/features/disable.coffee @@ -8,7 +8,12 @@ Rails.handleDisabledElement = (e) -> # Unified function to enable an element (link, button and form) Rails.enableElement = (e) -> - element = if e instanceof Event then e.target else e + if e instanceof Event + return if isXhrRedirect(e) + element = e.target + else + element = e + if matches(element, Rails.linkDisableSelector) enableLinkElement(element) else if matches(element, Rails.buttonDisableSelector) or matches(element, Rails.formEnableSelector) @@ -80,3 +85,7 @@ enableFormElement = (element) -> setData(element, 'ujs:enable-with', null) # clean up cache element.disabled = false setData(element, 'ujs:disabled', null) + +isXhrRedirect = (event) -> + xhr = event.detail?[0] + xhr?.getResponseHeader("X-Xhr-Redirect")? |