From 9e2c1fb42f02c423da1b0634ad1851b8e19a2bb9 Mon Sep 17 00:00:00 2001 From: zcdqs Date: Wed, 1 Feb 2023 12:03:12 +0000 Subject: [PATCH] fix grid layout on item count change Signed-off-by: zcdqs Change-Id: I76963dd1d366234c4f5d444743fbe30d7498eb60 --- .../pattern/grid/grid_scroll/grid_scroll_layout_algorithm.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 490a9e9504f..c04f82856e6 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; -- Gitee