Skip to content

Use $getId() as wire:key instead of rand #155

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

Closed

Conversation

neverything
Copy link

We ran into an issue when we were using the field for table filters with live() that the tree list kept closing after a single checkbox was clicked.

This PR changes wire:key="{{ rand() }}" to wire:key="{{ $getId() }}"

- keeps tree open when using as filter with live()
@mgkimsal
Copy link
Contributor

mgkimsal commented Apr 7, 2025

@neverything - this is similar to my PR #154 which uses a specific manageable treeKey and also adds the current url to the spa mode check.

hit the same issue you did (plus the spa check issue)

@CodeWithDennis
Copy link
Owner

CodeWithDennis commented Apr 8, 2025

Wouldnt this also cause problems with reactive / live?

A while back i tried this and ran into problems like that.

@neverything
Copy link
Author

@CodeWithDennis so far not, I'm using it with live() and have multiple filters per table. The only potential issue I could see is if the tree of options changes between requests.

@mgkimsal I like that approach. It would be cool if the default was still rand(), but allowing it to overwrite the wire:key if necessary using your approach from #154. Would you be open to a configurable approach @CodeWithDennis?

@CodeWithDennis
Copy link
Owner

CodeWithDennis commented Apr 8, 2025

Would you be open to a configurable approach @CodeWithDennis?

Yes! Lets do that to make sure we don't break anything! (Default rand until we find something better) @neverything

@neverything
Copy link
Author

@mgkimsal do you want to refresh your PR #154, or should I implement the configurable wire:key in mine?

@mgkimsal
Copy link
Contributor

mgkimsal commented Apr 9, 2025

@neverything - lemme look

Apologies for delay. I made a small change in 'setup' to add a 'rand' call as a suffix. Does that do what you were thinking of?

Would like to use this and keep the 'url()->current()' call in the spa() call check as well.

This is in #154

@CodeWithDennis
Copy link
Owner

Let me know when its ready to be checked, appreciate the help here guys. @mgkimsal @neverything

@CodeWithDennis
Copy link
Owner

#154

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.

3 participants