File tree Expand file tree Collapse file tree 1 file changed +8
-5
lines changed
core/src/components/datetime Expand file tree Collapse file tree 1 file changed +8
-5
lines changed Original file line number Diff line number Diff line change @@ -811,14 +811,17 @@ export class Datetime implements ComponentInterface {
811811
812812 private focusWorkingDay = ( currentMonth : Element ) => {
813813 /**
814- * Get the number of padding days so
814+ * Get the number of offset days so
815815 * we know how much to offset our next selector by
816816 * to grab the correct calendar-day element.
817817 */
818- const padding = currentMonth . querySelectorAll ( '.calendar-day-padding' ) ;
819- const { day, adjacentDay } = this . workingParts ;
820818
821- if ( day === null || adjacentDay ) {
819+ const { day, month, year } = this . workingParts ;
820+ const firstOfMonth = new Date ( `${ month } /1/${ year } ` ) . getDay ( ) ;
821+ const offset =
822+ firstOfMonth >= this . firstDayOfWeek ? firstOfMonth - ( this . firstDayOfWeek ) : 7 - ( this . firstDayOfWeek - firstOfMonth ) ;
823+
824+ if ( day === null ) {
822825 return ;
823826 }
824827
@@ -827,7 +830,7 @@ export class Datetime implements ComponentInterface {
827830 * and focus it.
828831 */
829832 const dayEl = currentMonth . querySelector (
830- `.calendar-day-wrapper:nth-of-type(${ padding . length + day } ) .calendar-day`
833+ `.calendar-day-wrapper:nth-of-type(${ offset + day } ) .calendar-day`
831834 ) as HTMLElement | null ;
832835 if ( dayEl ) {
833836 dayEl . focus ( ) ;
You can’t perform that action at this time.
0 commit comments