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

[V3] Return null on IntSynth when null is passed in #6478

Merged
merged 3 commits into from Aug 24, 2023
Merged

[V3] Return null on IntSynth when null is passed in #6478

merged 3 commits into from Aug 24, 2023

Conversation

ejonasson
Copy link
Contributor

The IntSynth in Livewire V3 adds the ability to convert an empty string that's passed into the synth to null. This is great on the frontend (since a form input will generally return '' instead of null, but there are still scenarios where null might be returned. For example, in a unit test (as demonstrated in the test on this PR), or when updated though Javascipt.

This PR just makes sure we pass though that null value in those cases, as opposed to passing it to the int cast, which converts it to 0.

1️⃣ Is this something that is wanted/needed? Did you create a discussion about it first?
Did not create a discussion, but an explanation is included above.

2️⃣ Did you create a branch for your fix/feature? (Master branch PR's will be closed)
Yes

3️⃣ Does it contain multiple, unrelated changes? Please separate the PRs out.
The only changes are to the IntSynth class, and adding a test for that Synth.

4️⃣ Does it include tests? (Required)
Yes

5️⃣ Please include a thorough description (including small code snippets if possible) of the improvement and reasons why it's useful.
Included above :)

@joshhanley joshhanley changed the title [v3] Return null on IntSynth when null is passed in [V3] Return null on IntSynth when null is passed in Aug 23, 2023
@joshhanley
Copy link
Member

@ejonasson thanks for the PR! I just pulled it down, and commented out your fix and the test still passes. Can you confirm the same happens for you?

@joshhanley
Copy link
Member

@ejonasson actually don't worry, I managed to fix it 🙂

@ejonasson
Copy link
Contributor Author

@joshhanley Oops, sorry about that. Thank you for fixing!

@calebporzio
Copy link
Collaborator

Thank you!

@calebporzio calebporzio merged commit 8993270 into livewire:main Aug 24, 2023
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants