@@ -658,6 +658,15 @@ const calculateVisibleRows = () => {
658
658
const buffer = props .bufferSize || 5 ;
659
659
const containerHeight = props .containerHeight || 900 ;
660
660
661
+ // For single item or small datasets, show all rows
662
+ if (props .rows .length <= buffer * 2 + 1 ) {
663
+ startIndex .value = 0 ;
664
+ endIndex .value = props .rows .length - 1 ;
665
+ visibleRows .value = props .rows ;
666
+ spacerHeight .value = 0 ;
667
+ return ;
668
+ }
669
+
661
670
// Binary search for start index
662
671
let low = 0 ;
663
672
let high = rowPositions .value .length - 1 ;
@@ -678,12 +687,17 @@ const calculateVisibleRows = () => {
678
687
newStartIndex + Math .ceil (containerHeight / (props .itemHeight || 52.5 )) + buffer * 2
679
688
);
680
689
681
- if (newStartIndex !== startIndex .value || newEndIndex !== endIndex .value ) {
690
+ // Ensure at least one row is visible
691
+ if (newEndIndex < newStartIndex ) {
692
+ startIndex .value = 0 ;
693
+ endIndex .value = Math .min (props .rows .length - 1 , Math .ceil (containerHeight / (props .itemHeight || 52.5 )));
694
+ } else {
682
695
startIndex .value = newStartIndex ;
683
696
endIndex .value = newEndIndex ;
684
- visibleRows .value = props .rows .slice (startIndex .value , endIndex .value + 1 );
685
- spacerHeight .value = startIndex .value > 0 ? rowPositions .value [startIndex .value - 1 ] : 0 ;
686
697
}
698
+
699
+ visibleRows .value = props .rows .slice (startIndex .value , endIndex .value + 1 );
700
+ spacerHeight .value = startIndex .value > 0 ? rowPositions .value [startIndex .value - 1 ] : 0 ;
687
701
};
688
702
689
703
// Throttled scroll handler
0 commit comments