designsystemet icon indicating copy to clipboard operation
designsystemet copied to clipboard

Combobox: null, undefined and empty string as value causes react to crash

Open Magnusrm opened this issue 11 months ago • 2 comments

Description of the bug

As mentioned in slack thread message: https://designsystemet.slack.com/archives/C05RF86A3K7/p1709550064585419?thread_ts=1709549317.707409&cid=C05RF86A3K7

The value of the generated Option object will be undefined if any of the mentioned values are used as a value. The object should be checked for undefined before it is attempted to retrieve the objects value property in order to mitigate a hard crash.

Steps To Reproduce

  1. Set up a simple react app in f.ex. codesandbox
  2. create a combobox with a controlled state that has initial value [""], [null] or [undefined]
  3. the react app will crash

Additional Information

No response

Magnusrm avatar Mar 11 '24 14:03 Magnusrm