diff --git a/frameworks/core/components_ng/pattern/grid/grid_scroll/grid_scroll_layout_algorithm.cpp b/frameworks/core/components_ng/pattern/grid/grid_scroll/grid_scroll_layout_algorithm.cpp index 490a9e9504fc0ef1d4f9604c6d176649c170c253..c04f82856e66a1cf22ef9cff36ddf73dc542bb7e 100644 --- a/frameworks/core/components_ng/pattern/grid/grid_scroll/grid_scroll_layout_algorithm.cpp +++ b/frameworks/core/components_ng/pattern/grid/grid_scroll/grid_scroll_layout_algorithm.cpp @@ -777,14 +777,14 @@ void GridScrollLayoutAlgorithm::UpdateMatrixForDeletedItems(int32_t deletedLineC decltype(gridLayoutInfo_.lineHeightMap_) gridLineHeightMap(std::move(gridLayoutInfo_.lineHeightMap_)); decltype(gridLayoutInfo_.gridMatrix_) gridMatrix(std::move(gridLayoutInfo_.gridMatrix_)); for (const auto& item : gridMatrix) { - if (item.first == 0) { + if (item.first <= currentMainLineIndex_) { gridLayoutInfo_.gridMatrix_[item.first] = item.second; } else { gridLayoutInfo_.gridMatrix_[item.first - deletedLineCount] = item.second; } } for (const auto& item : gridLineHeightMap) { - if (item.first == 0) { + if (item.first <= currentMainLineIndex_) { gridLayoutInfo_.lineHeightMap_[item.first] = item.second; } else { gridLayoutInfo_.lineHeightMap_[item.first - deletedLineCount] = item.second;