Skip to content

Feature/stimulus#1010

Open
tagliala wants to merge 3 commits intomainfrom
feature/stimulus
Open

Feature/stimulus#1010
tagliala wants to merge 3 commits intomainfrom
feature/stimulus

Conversation

@tagliala
Copy link
Copy Markdown
Contributor

No description provided.

Rails ships Stimulus by default, making it the natural host for
client-side validation lifecycle management. The previous runtime
auto-booted from a UMD bundle served by Sprockets or Webpacker,
required manual enable/disable calls, and used a custom jQuery-era
event loop that did not handle dynamically inserted fields.

This commit replaces all of that with a single Stimulus controller
(identifier: client-side-validations) that owns the full lifecycle:

- Form context is installed in connect() and torn down in disconnect()
- Validated inputs are declared as Stimulus targets; new inputs added
  via Turbo Stream, cocoon, or nested-form are picked up automatically
  through inputTargetConnected / inputTargetDisconnected
- Confirmation fields use a dedicated 'confirmation' target with a
  data-client-side-validations-confirms attribute pointing to the
  primary field's id
- Settings travel as a Stimulus value (data-...-settings-value) so
  the controller owns both config and lifecycle with no global state

Breaking changes:
- window.ClientSideValidations global and its enable/validate/disable/
  reset API are removed; use the Stimulus controller lifecycle instead
- data-client-side-validations attribute replaced by the settings value
- UMD bundle and Sprockets/Webpacker asset generators removed; the gem
  now ships a single ESM bundle consumed via the npm package
- ajax:beforeSend / remote: true integration removed; validation runs
  on the native submit event
- Stimulus >= 3.2 is now a peer dependency

The install generator now copies a Stimulus controller stub into
app/javascript/controllers/ alongside the existing initializer.
A new Config.stimulus_controller_name option allows projects to mount
the controller under a custom identifier.

Close #929
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant