Hacker0x01 / react-datepicker

A simple and reusable datepicker component for React
https://reactdatepicker.com/
MIT License
8.09k stars 2.24k forks source link

The crash occurs if 'this.centerLi' is undefined in time.jsx. PR with fix provided. #3790

Open nikolasbo opened 2 years ago

nikolasbo commented 2 years ago

We came across the case when if block: if (isBefore(time, activeTime) || isEqual(time, activeTime)) { this.centerLi = li; } will result in false and this.centerLi = undefined. It will cause the APP crash with message:

crash

One possible solution is to add a condition to this (https://github.com/Hacker0x01/react-datepicker/blob/master/src/time.jsx): this.list.scrollTop = this.centerLi && Time.calcCenterPosition( this.props.monthRef ? this.props.monthRef.clientHeight - this.header.clientHeight : this.list.clientHeight, this.centerLi );

PR: https://github.com/Hacker0x01/react-datepicker/pull/3786

github-actions[bot] commented 4 months ago

This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 10 days.