Replace jquery-ujs with @hotwired/turbo#2448
Conversation
6b3c858 to
dd95787
Compare
3259381 to
c3074a0
Compare
|
@seanpdoyle Thank you for doing this. What are your thoughts on replacing this |
spec/example_app/app/views/admin/customers/_collection_item_actions.html.erb
Show resolved
Hide resolved
a78a5ca to
ee358f4
Compare
09f2953 to
43da734
Compare
965dc25 to
7a9ec8f
Compare
19a2e6e to
66497ef
Compare
f667fba to
bc718a1
Compare
8e8dbb2 to
d38f8fa
Compare
Replace our client-side dependency on `jquery-ujs` with
[@hotwired/turbo][].
In addition to adding an entry to the `package.json` file, this commit
replaces `[data-confirm]` attributes with `[data-turbo-confirm]`, and
`[data-method]` attributes with `[data-turbo-method]`.
In an effort to minimize the diff, this commit *does not* replace the
`link_to` calls made with `method: :delete` with [button_to][] calls.
Ideally, they'd utilize `button_to` to render a `<form>` element for the
destructive action.
In the future, once that change is complete, the `data: {turbo_method:
:delete}` attributes can once again be passed as `method: :delete`
options.
[@hotwired/turbo]: https://turbo.hotwired.dev
[turbo-rails]: https://github.com/hotwired/turbo-rails
[link_to]: https://edgeapi.rubyonrails.org/classes/ActionView/Helpers/UrlHelper.html#method-i-link_to
[button_to]: https://edgeapi.rubyonrails.org/classes/ActionView/Helpers/UrlHelper.html#method-i-button_to
|
Thanks again for keeping this up to date, @seanpdoyle! |
|
Thank you for pushing this forward! Just to highlight some troubles: this PR seems to introduce some test flakiness with regard to the search field. I'm not sure about the cause, since the #2447 PR was the one responsible for modifying how those test drive the search behavior. It's something to monitor in the future. |
|
Ah, interesting, thanks! I'll keep an eye on it and open an issue if it keeps happening. I know on a certain client project we had some trouble with the way we're using to writing feature/system specs and test flakiness and I might need some help digging into it. |
This takes the same approach as in this `administrate` PR [1] by adding the `data-turbo-method` and `data-turbo-confirm` attributes supported by Hotwire Turbo [2,3] to the link for removing an attachment. The existing `method` option and `data-confirm` attribute are left in place to avoid breaking the behaviour under UJS [4] which was deprecated in Rails v7 and removed in Rails v7.2.A As the `administrate` PR says, ideally the `link_to` would be replaced by `button_to`. However, in the interests of making the change as small as possible and retaining consistency with `administrate` itself, it seems OK to keep the `link_to` in place. [1]: thoughtbot/administrate#2448 [2]: https://turbo.hotwired.dev/handbook/drive#performing-visits-with-a-different-method [3]: https://turbo.hotwired.dev/handbook/drive#requiring-confirmation-for-a-visit [4]: https://api.rubyonrails.org/v7.0/classes/ActionView/Helpers/UrlHelper.html#method-i-link_to-label-Deprecated-3A+Rails+UJS+Attributes
This takes the same approach as in this `administrate` PR [1] by adding the `data-turbo-method` and `data-turbo-confirm` attributes supported by Hotwire Turbo [2,3] to the link for removing an attachment. The existing `method` option and `data-confirm` attribute are left in place to avoid breaking the behaviour under UJS [4] which was deprecated in Rails v7 and removed in Rails v7.2. As the `administrate` PR says, ideally the `link_to` would be replaced by `button_to`. However, in the interests of making the change as small as possible and retaining consistency with `administrate` itself, it seems OK to keep the `link_to` in place. [1]: thoughtbot/administrate#2448 [2]: https://turbo.hotwired.dev/handbook/drive#performing-visits-with-a-different-method [3]: https://turbo.hotwired.dev/handbook/drive#requiring-confirmation-for-a-visit [4]: https://api.rubyonrails.org/v7.0/classes/ActionView/Helpers/UrlHelper.html#method-i-link_to-label-Deprecated-3A+Rails+UJS+Attributes
This takes the same approach as in this `administrate` PR [1] by adding the `data-turbo-method` and `data-turbo-confirm` attributes supported by Hotwire Turbo [2,3] to the link for removing an attachment. The existing `method` option and `data-confirm` attribute are left in place to avoid breaking the behaviour under UJS [4] which was deprecated in Rails v7 and removed in Rails v7.2. As the `administrate` PR says, ideally the `link_to` would be replaced by `button_to`. However, in the interests of making the change as small as possible and retaining consistency with `administrate` itself, it seems OK to keep the `link_to` in place. [1]: thoughtbot/administrate#2448 [2]: https://turbo.hotwired.dev/handbook/drive#performing-visits-with-a-different-method [3]: https://turbo.hotwired.dev/handbook/drive#requiring-confirmation-for-a-visit [4]: https://api.rubyonrails.org/v7.0/classes/ActionView/Helpers/UrlHelper.html#method-i-link_to-label-Deprecated-3A+Rails+UJS+Attributes
This takes the same approach as in this `administrate` PR [1] by adding the `data-turbo-method` and `data-turbo-confirm` attributes supported by Hotwire Turbo [2,3] to the link for removing an attachment. The existing `method` option and `data-confirm` attribute are left in place to avoid breaking the behaviour under UJS [4] which was deprecated in Rails v7 and removed in Rails v7.2. As the `administrate` PR says, ideally the `link_to` would be replaced by `button_to`. However, in the interests of making the change as small as possible and retaining consistency with `administrate` itself, it seems OK to keep the `link_to` in place. [1]: thoughtbot/administrate#2448 [2]: https://turbo.hotwired.dev/handbook/drive#performing-visits-with-a-different-method [3]: https://turbo.hotwired.dev/handbook/drive#requiring-confirmation-for-a-visit [4]: https://api.rubyonrails.org/v7.0/classes/ActionView/Helpers/UrlHelper.html#method-i-link_to-label-Deprecated-3A+Rails+UJS+Attributes
Replace our client-side dependency on
jquery-ujswith@hotwired/turbo.
In addition to adding an entry to the
package.jsonfile, this commitreplaces
[data-confirm]attributes with[data-turbo-confirm], and[data-method]attributes with[data-turbo-method].In an effort to minimize the diff, this commit does not replace the
link_tocalls made withmethod: :deletewith button_to calls.Ideally, they'd utilize
button_toto render a<form>element for thedestructive action.
In the future, once that change is complete, the
data: {turbo_method: :delete}attributes can once again be passed asmethod: :deleteoptions.