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

Deleting a resource from the edit page with the UsesResourceLock trait results in an error before redirecting #39

Open
adriaardila opened this issue May 9, 2024 · 6 comments

Comments

@adriaardila
Copy link
Contributor

adriaardila commented May 9, 2024

When attempting to delete a resource from the edit page, it throws an error before redirecting the user to the index page / table.

image

It happens on all edit pages (for example EditContact) that have the use usesresourcelock trait

@Jehizkia
Copy link
Member

Jehizkia commented May 9, 2024

Hi, thank you for reporting. Could you please share the entire error page of your screenshot with the share button on the top right so I can inspect it?

@adriaardila
Copy link
Contributor Author

adriaardila commented May 10, 2024

Hi, thank you for reporting. Could you please share the entire error page of your screenshot with the share button on the top right so I can inspect it?

Here you go:

https://flareapp.io/share/NPLojdgm

I don't think the error will be of much help since it does not crash on your code specifically, the problem is that when you delete a model the $record ceases to exist, so maybe in the trait you need to check that the $record is initialized before attempting to access it

@Jehizkia
Copy link
Member

Looking at the errors, it fails when the getRecord() function is called. But the UsesResourceLock trait doesn't call this function at all. Seems like this originates from the RelationManager.

@adriaardila
Copy link
Contributor Author

@Jehizkia yes, but once I remove the HasLocks trait it works fine, the HasLocks trait uses the $record variable, the problem is that it doesn't check that that variable is always existant and when you delete a record there's a split second where the Livewire component of the EditRecord is reloaded, and then attempts to load the $record called in your trait but that record does not exist anymore. Maybe could be worth checking that the $record is initialized before attempting to access it in the trait.

I can do a PR later and see if I can fix it.

Thank you

@Jehizkia
Copy link
Member

@adriaardila Ah, I see what you mean. Yeah, if you could whip something up, I’ll give it a look.👌

@adriaardila
Copy link
Contributor Author

@Jehizkia sure, btw I also added something that I need for my project and did a PR on that, it's an option to disable the navigation on the sidebar if needed.

#41

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

No branches or pull requests

2 participants