iamjey6 / test

0 stars 0 forks source link

if includes three #17

Open iamjey6 opened 8 months ago

iamjey6 commented 8 months ago

Proposal

Please re-state the problem that we are trying to solve in this issue.

If the user is on the last day of the month and then goes back to the previous month in the request money date field, it causes the forward button to become disabled.

What is the root cause of that problem?

The problem stems from the date comparison logic, which doesn't handle the last day of the month scenario properly in the following line:

https://github.com/Expensify/App/blob/4ebeea00ebf1470bbf085a51cb9b9ec0735cf511/src/components/NewDatePicker/CalendarPicker/index.js#L128

What changes do you think we should make in order to solve the problem?

To solve this problem, we should modify the calculation for hasAvailableDatesNextMonth to consider the start of the next month, as in our case the current date plus one month may be greater than the max date's month time.

const hasAvailableDatesNextMonth = moment(this.props.maxDate).endOf('month').startOf('day') > moment(this.state.currentDateView).add(1, 'months').startOf('month');

By adding .startOf('month') to the comparison, we are comparing the start of the next month with the start of the user's selected month, regardless of whether the current date is the last day of the month or not.