Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: message don't appear on fail destroy on associations #2016

Merged

Conversation

Paul-Bob
Copy link
Contributor

@Paul-Bob Paul-Bob commented Nov 6, 2023

Description

Fixes #1918

Turbo stream errors on destroy should be more efficient and error proof

Before

before.webm

After

after.webm

Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works

Manual review steps

  1. Step 1
  2. Step 2

Manual reviewer: please leave a comment with output from the test if that's the case.

@Paul-Bob Paul-Bob added the Fix label Nov 6, 2023
@Paul-Bob Paul-Bob self-assigned this Nov 6, 2023
Copy link

codeclimate bot commented Nov 6, 2023

Code Climate has analyzed commit c9afba0 and detected 0 issues on this pull request.

View more on Code Climate.

Copy link
Collaborator

@adrianthedev adrianthedev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we please add some tests for this use-case?
Then we can merge it.

respond_to do |format|
format.html { redirect_back fallback_location: params[:referrer] || resources_path(resource: @resource, turbo_frame: params[:turbo_frame], view_type: params[:view_type]), error: destroy_fail_message }
format.turbo_stream { render partial: "avo/partials/flash_alerts" }
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure that removing the redirect does not break other flows?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

None that I tested or that is covered by automatic tests

@@ -1,3 +1,3 @@
<%= turbo_stream.append "alerts" do %>
<%= render Avo::FlashAlertsComponent.new flashes: flash %>
<%= render Avo::FlashAlertsComponent.new flashes: flash.discard %>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we sure that the discard works well with other flows as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think so, it will discard the entire flash at the end of the current action

@Paul-Bob Paul-Bob merged commit 869bce2 into main Nov 15, 2023
10 checks passed
@Paul-Bob Paul-Bob deleted the fix/message_do_not_appear_on_fail_destroy_on_associations branch November 15, 2023 16:46
Copy link
Contributor

This PR has been merged into main. The functionality will be available in the next release.

Please check the release guide for more information.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Deleting a record with validation errors within has_many view hangs on reloading view
2 participants