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

[ic-text-field] Setting an IcTextField's value to 'undefined' throws an error in the console #2813

Open
janfaracik opened this issue Nov 21, 2024 · 1 comment
Labels
type: bug 🐛 Something isn't working

Comments

@janfaracik
Copy link
Contributor

Summary of the bug

Setting an IcTextField's value to 'undefined' throws an error in the console. We want to set the value of our input against a prop (that may or may not be there) of a map, but when the prop isn't there an error is thrown from the component due to its value being undefined.

Checking the type for the text field's value field says that it's optional, so I'd expect it to allow for undefined values.

🪜 How to reproduce

  1. Add a text field to your page, e.g. <IcTextField name={'test'} label={'test'} value={undefined} />
  2. Check the console:

image

🖥 📱 Device

  • Type: Desktop
  • Device: MacBook Pro
  • OS version: macOS Sequoia
  • Browser version: Safari 18.1 (but any browser)

🧐 Expected behaviour

I'd expect undefined to be a valid value for the 'value' property of an IcTextField, and for it to not throw an error in the console.

Additional info

Unsure if this impacts other form components.

@evenstensberg
Copy link
Contributor

A PR would be great. I can fix this, but it's a good first issue. Just do the same changes as in this PR #2182 to check if the textfield prop is undefined. If it is, assign it an empty string

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug 🐛 Something isn't working
Projects
Status: No status
Development

No branches or pull requests

2 participants