Skip to content

Remove @rails/ujs#4074

Draft
tvdeyen wants to merge 3 commits into
mainfrom
remove-rails-ujs
Draft

Remove @rails/ujs#4074
tvdeyen wants to merge 3 commits into
mainfrom
remove-rails-ujs

Conversation

@tvdeyen

@tvdeyen tvdeyen commented Jul 19, 2026

Copy link
Copy Markdown
Member

What is this pull request for?

Built on top of #4069. That PR converted the element editor save — the last
admin form driven by @rails/ujs — to Turbo, which leaves nothing in the admin
depending on UJS. This removes the library and its remaining dead footprint.

There are no remaining remote forms or links, every destructive link is a Turbo
form or uses data-turbo-method/data-turbo-confirm, utils/ajax handles its
own CSRF token, and the only Rails.* call left was Rails.start() itself.

Removed:

The library — the import Rails from "@rails/ujs", Rails.start(), the
importmap pin, the vendored rails-ujs.min.js, the package.json dependency
and the rollup external entry.

Its dead consumers — the dialog's watch_remote_forms (it bound
ajax:success/ajax:error on [data-remote="true"] forms, of which there are
none); the vestigial remote: plumbing in the kaminari pagination theme (no
caller ever passed it, so the pagination links were already plain Turbo Drive
navigations, not data-remote); and the three server-side js.erb responses
(redirect, permission_denied, error_notice) with their format.js
branches. Those only did anything because UJS auto-executed a
text/javascript response — nothing requests a :js format anymore, so they
were unreachable.

Notable changes (remove if none)

Requests that reach do_redirect_to, show_error_notice or the guest
permission-denied path with a :js format previously rendered a js.erb; they
now fall through to the turbo_stream/html/500/redirect branches that real
(Turbo and fetch) clients already use.

Checklist

  • I have followed Pull Request guidelines
  • I have added a detailed description into each commit message
  • I have added tests to cover this change

@tvdeyen
tvdeyen requested a review from a team as a code owner July 19, 2026 08:56
@tvdeyen tvdeyen added this to the 8.4 milestone Jul 19, 2026
@tvdeyen
tvdeyen force-pushed the element-editor-turbo-stream branch from caaf57d to 78fcc6f Compare July 19, 2026 09:18
Base automatically changed from element-editor-turbo-stream to main July 19, 2026 09:25
@tvdeyen
tvdeyen force-pushed the remove-rails-ujs branch from 7a46ac6 to e2bde52 Compare July 19, 2026 09:33
tvdeyen added 3 commits July 19, 2026 11:40
The element editor save was the last remote form driven by @rails/ujs; with it
converted to Turbo, nothing in the admin depends on UJS anymore. No remote
forms or links remain, all destructive links are Turbo forms or use
data-turbo-method/confirm, and the only Rails.* call left was Rails.start().

This removes the library (import, Rails.start(), the importmap pin, the
vendored rails-ujs.min.js, the package.json dependency and the rollup external)
together with its now-dead consumers: the dialog's watch_remote_forms handler,
the vestigial remote: plumbing in the kaminari pagination theme (no caller ever
enabled it, so the links were already plain Turbo Drive navigations), and the
server-side js.erb responses (redirect, permission_denied, error_notice) that
only ran because UJS auto-executed a text/javascript response. Nothing requests
a :js format anymore, so those format.js branches were unreachable.
alchemy_form_for defaulted the form to a UJS remote request for XHR
requests. With @rails/ujs gone that default no longer does anything, and
every caller already opted out of it with remote: false. Drop the defaulting
and the now no-op remote: false arguments.
redirect_or_render_notice answered an XHR permission denial with a
respond_to that rendered plain text for a text/javascript (UJS remote)
request and the flash partial for everything else. Only a UJS client ever
asked for the JavaScript variant, so render the flash partial directly.
@tvdeyen
tvdeyen force-pushed the remove-rails-ujs branch from e2bde52 to 46dc0f4 Compare July 19, 2026 09:47
@tvdeyen
tvdeyen marked this pull request as draft July 19, 2026 10:05
@tvdeyen

tvdeyen commented Jul 19, 2026

Copy link
Copy Markdown
Member Author

Blocked: converting to draft. CI surfaced that admin dialog forms depend on @rails/ujs — a form rendered in a dialog is implicitly made data-remote by alchemy_form_for's remote: request.xhr? default (dialogs load via an xhr fetch), UJS submits it, and dialog.js#watch_remote_forms injects the response (success + validation-error renders) back into the dialog body. dialog.js has no Turbo form handling, so removing UJS breaks dialog form submission/validation across the admin (pages, resources, pictures, nodes, …). The dialog form-submission flow needs to be converted to Turbo first; this PR will rebase on top of that.

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