@@ -141,6 +141,10 @@ export const applyNavigationBounds = (args: { date: Date; min?: Date; max?: Date
141141 } ;
142142} ;
143143
144+ const isMonthMatch = ( date1 : Date , date2 : Date ) => {
145+ return date1 . getMonth ( ) === date2 . getMonth ( ) && date1 . getFullYear ( ) === date2 . getFullYear ( ) ;
146+ } ;
147+
144148/**
145149 * Decide if date has to be focusable with Tab (only one date should be)
146150 * 1. If there is a selected value - it's focusable
@@ -154,17 +158,13 @@ export const isDateFocusable = (args: {
154158} ) => {
155159 const { date, startValue, lastFocusedDate } = args ;
156160 const today = new Date ( ) ;
157- const renderedMonth = date . getMonth ( ) ;
158- const valueMonth = startValue ?. getMonth ( ) ;
159- const todayMonth = today . getMonth ( ) ;
160- const lastFocusedMonth = lastFocusedDate ?. getMonth ( ) ;
161161 const isoDate = getLocalISODate ( { date } ) ;
162162 const isoToday = getLocalISODate ( { date : today } ) ;
163163 const isoValueDate = startValue && getLocalISODate ( { date : startValue } ) ;
164164 const isoLastFocusedDate = lastFocusedDate && getLocalISODate ( { date : lastFocusedDate } ) ;
165165
166- if ( lastFocusedDate && renderedMonth === lastFocusedMonth ) return isoDate === isoLastFocusedDate ;
167- if ( startValue && renderedMonth === valueMonth ) return isoDate === isoValueDate ;
168- if ( renderedMonth === todayMonth ) return isoDate === isoToday ;
166+ if ( lastFocusedDate && isMonthMatch ( date , lastFocusedDate ) ) return isoDate === isoLastFocusedDate ;
167+ if ( startValue && isMonthMatch ( date , startValue ) ) return isoDate === isoValueDate ;
168+ if ( isMonthMatch ( date , today ) ) return isoDate === isoToday ;
169169 return true ;
170170} ;
0 commit comments