Skip to content

feat(forms): allow null as initial value #2275

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

Merged
merged 17 commits into from
Oct 1, 2024

Conversation

Gerbuuun
Copy link
Contributor

@Gerbuuun Gerbuuun commented Sep 28, 2024

🔗 Linked issue

Resolves #1210

❓ Type of change

  • 📖 Documentation (updates to the documentation or readme)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • 👌 Enhancement (improving an existing functionality)
  • ✨ New feature (a non-breaking change that adds functionality)
  • 🧹 Chore (updates to the build process or auxiliary tools and libraries)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

📚 Description

Added a model modifier to UInput and UTextarea to make the value return null if the field value is falsy (because initial values may not be a string?).
I'm not actually sure if the type change is allowed like this.
Does the native element support an initial value of null? I suppose it is similar to undefined...

📝 Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.
@benjamincanac benjamincanac changed the title feat: add nullable modifier to input and textarea Sep 30, 2024
@benjamincanac benjamincanac changed the title feat(Input/Textarea): add nullable modifier Sep 30, 2024
Gerbuuun and others added 2 commits September 30, 2024 13:52
Co-authored-by: Romain Hamel <rom.hml@gmail.com>
Co-authored-by: Romain Hamel <rom.hml@gmail.com>
@Gerbuuun
Copy link
Contributor Author

I've created a new feature request for the model modifier (#2281). I'll update this PR to only include the type changes. After that we can discuss the modifier.

@Gerbuuun Gerbuuun changed the title feat(Input/Textarea): add nullable modifier Sep 30, 2024
@Gerbuuun Gerbuuun requested a review from romhml September 30, 2024 12:57
@Gerbuuun Gerbuuun changed the title feat(Input/Textarea): allow null as initial value Sep 30, 2024
Copy link
Member

@romhml romhml left a comment

Choose a reason for hiding this comment

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

Thanks :)

@benjamincanac benjamincanac changed the title feat: allow null as initial value Oct 1, 2024
@benjamincanac benjamincanac merged commit 474accb into nuxt:dev Oct 1, 2024
2 checks passed
@benjamincanac
Copy link
Member

@romhml Do we need to do this on v3 as well?

@romhml
Copy link
Member

romhml commented Oct 1, 2024

Yes, I'll take care of it.

patrick-hofmann pushed a commit to patrick-hofmann/nuxt-ui that referenced this pull request Oct 3, 2024
Co-authored-by: Romain Hamel <rom.hml@gmail.com>
@Gerbuuun
Copy link
Contributor Author

Now actually trying this (@nuxt/ui@2.18.7) it does not seem to work...
Is there a difference with component types between the playground and actual package?

Can someone confirm this works?

@valh1996
Copy link

valh1996 commented Dec 9, 2024

Now actually trying this (@nuxt/ui@2.18.7) it does not seem to work... Is there a difference with component types between the playground and actual package?

Can someone confirm this works?

Hello @Gerbuuun
I thought it might come from vuejs/language-tools and that null was not included in the type definition after all.

But @KazariEX found the problem (Thank you !) and it is in the tsconfig configuration :

After investigation, it was found that the issue is with @nuxt/ui, which set strictNullCheck to false in TSConfig, causing the null that should have existed to be erased from the type when compiling the component.

I'm going to create a new issue to see if we can find a solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
4 participants