sfx2/source/control/thumbnailview.cxx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
New commits: commit 4bb0ffa4684dada708ecdf727f4fc9f500a9bced Author: Katarina Behrens <bu...@bubli.org> AuthorDate: Fri Jan 28 18:03:58 2022 +0100 Commit: Katarina Behrens <bu...@bubli.org> CommitDate: Sat Jan 29 09:58:54 2022 +0100 tdf#122708: on GetFocus, select something also when items are filtered Previously if nothing was selected, we picked item with ID 1 to select/highlight. But if a filter is active, such item may not match the active filter (case in point: document template no. 1 matches 'Writer templates' filter, but not 'Impress templates' one) Try harder to find an item to select by looking at the list of filtered items too Change-Id: I9cb053b884dc724c7a6199ec002d83024ed83976 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129117 Tested-by: Jenkins Reviewed-by: Katarina Behrens <bu...@bubli.org> diff --git a/sfx2/source/control/thumbnailview.cxx b/sfx2/source/control/thumbnailview.cxx index 37043f8767c0..3e85c4c911fc 100644 --- a/sfx2/source/control/thumbnailview.cxx +++ b/sfx2/source/control/thumbnailview.cxx @@ -924,7 +924,14 @@ void ThumbnailView::GetFocus() if (nSelected == -1 && !mItemList.empty()) { - SelectItem(1); + ThumbnailViewItem* pFirst = nullptr; + if (!mFilteredItemList.empty()) { + pFirst = mFilteredItemList[0]; + } else { + pFirst = mItemList[0].get(); + } + + SelectItem(pFirst->mnId); } }