-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Closed
Description
Issue summary
When a TextField
component is given a value of null
, an error is thrown saying cannot read property length of null.
Expected behavior
Providing a null
value should render a TextField
with no contents.
Actual behavior
The following error is thrown:
Uncaught TypeError: Cannot read property 'length' of null
at TextField.render (index.es.js:5177)
This appears to be due to the character count trying to check the length of the value. Ideally null
shouldn't be passed to a TextField
, but I would expect just the typical warning from React about an uncontrolled component and not a crash.
This is the piece of code in TextField.tsx that's crashing:
const characterCount = value.length;
I think a simple fix would be:
const characterCount = value ? value.length : 0;
Steps to reproduce the problem
- Create the following component:
<TextField value={null} />
Reduced test case
The following code sandbox reproduces the issue: https://codesandbox.io/s/1omnl2q7vj
Specifications
- Are you using the React components? (Y/N): Y
- Polaris version number: 3.6.0
- Browser: Chrome 72.0.3626.81 (Official Build) (64-bit)
- Device: MacBook Pro
- Operating System: macOS High Sierra 10.14.3
Metadata
Metadata
Assignees
Labels
No labels