1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

Fix scrolling to items on search

Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
This commit is contained in:
Alex Andreev 2022-09-06 19:28:01 +03:00
parent 7b53650628
commit 05a3ed0e57
2 changed files with 6 additions and 2 deletions

View File

@ -81,8 +81,10 @@ export const LogList = observer(({ model }: LogListProps) => {
}, [model.logTabData.get()]);
useEffect(() => {
rowVirtualizer.scrollToIndex(model.searchStore.occurrences[model.searchStore.activeOverlayIndex], { align: 'end', smoothScroll: false });
}, [model.searchStore.activeOverlayIndex])
if (!model.searchStore.occurrences.length) return;
scrollTo(model.searchStore.occurrences[model.searchStore.activeOverlayIndex]);
}, [model.searchStore.searchQuery, model.searchStore.activeOverlayIndex])
return (
<div

View File

@ -123,6 +123,8 @@ export class SearchStore {
* @returns A line index within the text/logs array
*/
@computed get activeOverlayLine(): number {
if (!this.occurrences.length) return -1;
return this.occurrences[this.activeOverlayIndex];
}