sandstone
sandstone copied to clipboard
WRQ-31515: Fixed `Scroller`, `Slider`, `VirtualList` and `VirtualGridList` to set prop value to default when `undefined` is passed for the prop value
Checklist
- [x] I have read and understand the contribution guide
- [x] A CHANGELOG entry is included
- [ ] At least one test case is included for this feature or bug fix
- [x] Documentation was added or is not needed
- [ ] This is an API breaking change
Issue Resolved / Feature Added
In https://github.com/enactjs/sandstone/pull/1613, we removed defaultProps and implemeted this feature manually.
After this implementation, if undefined
is passed for a prop value, the prop value remains undefined.
However, defaultProps(https://legacy.reactjs.org/docs/typechecking-with-proptypes.html#default-prop-values) sets prop value to default value when undefined value is passed for the prop.
Resolution
Fix Scroller
, Slider
, VirtualList
and VirtualGridList
to set prop value to default value when undefined
is passed for the prop value
Additional Considerations
-
I checked React's defaultProps for falsy values(null, undefined, false, NaN, 0, -0, "") and found that it sets the prop value to its default value only when undefined is passed. https://react.dev/reference/react/Component#static-defaultprops
-
I found that the default value of wheelInterval in controls of Slider sampler was not loading properly. So I fixed it in this PR. https://github.com/enactjs/sandstone/pull/1658/files#diff-4f80023ae6bb7b165147824d15263e1a011ab278fdf4a5f6ddbea07fecca1a31R471
Links
WRQ-31515