@@ -292,6 +292,13 @@ export default class ViewDataProvider {
292292 let resultCellColumnIndex = - 1 ;
293293 let resultCellRowIndex = - 1 ;
294294
295+ const getCellPosition = ( rowIndex : number , cellIndex : number ) => ( {
296+ columnIndex : rowIndex ,
297+ rowIndex : showAllDayPanel && ! this . _options . isVerticalGrouping
298+ ? cellIndex - 1
299+ : cellIndex ,
300+ } ) ;
301+
295302 for ( let rowIndex = 0 ; rowIndex < completeViewDataMap . length ; rowIndex += 1 ) {
296303 const currentRow = completeViewDataMap [ rowIndex ] ;
297304
@@ -304,40 +311,38 @@ export default class ViewDataProvider {
304311 allDay : cellAllDay ,
305312 } = cellData ;
306313
307- if ( groupIndex !== cellGroupIndex || allDay !== cellAllDay ) {
314+ if ( groupIndex !== cellGroupIndex || allDay !== Boolean ( cellAllDay ) ) {
308315 continue ;
309316 }
310317
311318 const isDateInCell = allDay
312319 ? dateUtils . sameDate ( date , cellStartDate )
313320 : date >= cellStartDate && date < cellEndDate ;
314321
322+ if ( isDateInCell ) {
323+ return {
324+ position : getCellPosition ( columnIndex , rowIndex ) ,
325+ cellData
326+ } ;
327+ }
328+
315329 const diff = Math . min (
316330 Math . abs ( date . getTime ( ) - cellStartDate . getTime ( ) ) ,
317331 Math . abs ( date . getTime ( ) - cellEndDate . getTime ( ) ) ,
318332 ) ;
319333
320- if ( isDateInCell || ( findClosest && diff < resultDiff ) ) {
334+ if ( findClosest && diff < resultDiff ) {
321335 resultDiff = diff ;
322336 resultCellData = cellData ;
323337 resultCellColumnIndex = columnIndex ;
324338 resultCellRowIndex = rowIndex ;
325-
326- if ( isDateInCell ) {
327- break ;
328- }
329339 }
330340 }
331341 }
332342
333343 return resultCellData
334344 ? {
335- position : {
336- columnIndex : resultCellColumnIndex ,
337- rowIndex : showAllDayPanel && ! this . _options . isVerticalGrouping
338- ? resultCellRowIndex - 1
339- : resultCellRowIndex ,
340- } ,
345+ position : getCellPosition ( resultCellColumnIndex , resultCellRowIndex ) ,
341346 cellData : resultCellData ,
342347 }
343348 : undefined ;
0 commit comments