Repository navigation
Ensure disabled state works as expected by changing links to buttons - #51
Merged
Merged
Conversation
* Use WeakSet to avoid attaching multiple event handlers to the same element from multiple init() calls * Append hidden input within the button_to form to contain all selected batch_action_ids * Set Button disabled as default state * Ensure data-confirm is pulled into confirmation dialog (Rails 7+ doesn't confirm with UJS)
# Conflicts: # app/assets/javascripts/administrate_batch_actions/script.js
- Only show a confirm dialog when a confirm message is given, and use data-batch-action-confirm so rails-ujs doesn't prompt a second time - Let the native form submission proceed instead of form.submit(), only preventing it when the confirm is cancelled - Replace previously appended hidden ids so a resubmit doesn't duplicate them - Fix inverted back/forward cache reset and re-sync button state - Opt the form out of Turbo to keep the previous full-page POST behavior - Find each button's form via button.form instead of form:has() - Tidy partial formatting
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Supersedes #48 by @joshmfrankel. His commits are included unchanged, plus a merge of
mainand one commit addressing the review feedback. I couldn't push to the fork directly.From #48
button_toforms, disabled by default, so the disabled state actually worksinit()(DOMContentLoaded / turbo:load) from binding handlers twicebatch_action_ids[]inputsFollow-up fixes (review feedback)
confirm:is given. Before, every submission prompted "Are you sure you want to submit this form?"data-batch-action-confirmso rails-ujs doesn't show a second dialog forbutton[data-confirm]preventDefault()+form.submit()length === 0→> 0) and re-sync button state afterwardsdata-turbo="false"to keep the previous full-page POST behavior, so existing batch actions thatredirect_tokeep working under Turbo. This also covers theturbo_methodTODO.button.formreplaces theform:has(...)selectoraction; added a spec for thisBreaking for custom CSS/JS
<button>inside a<form class="button_to">, not an<a class="btn disabled">data-confirmon the button is nowdata-batch-action-confirmTesting
bundle exec rspec: 10 examples, 0 failuresinit()doesn't double-bind