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

Horizontal scrolling to founded keyword

Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
This commit is contained in:
Alex Andreev 2020-11-05 09:29:34 +03:00
parent cc8902c32b
commit c3c2e527ee
2 changed files with 12 additions and 0 deletions

View File

@ -116,7 +116,12 @@ export class PodLogs extends React.Component<Props> {
toOverlay() {
const { activeOverlayLine } = searchStore;
if (!this.virtualListRef.current || activeOverlayLine === undefined) return;
// Scroll vertically
this.virtualListRef.current.scrollToItem(activeOverlayLine, "center");
// Scroll horizontally
const overlay = document.querySelector(".PodLogs .list span.active");
if (!overlay) return;
overlay.scrollIntoViewIfNeeded();
}
/**

7
types/dom.d.ts vendored Normal file
View File

@ -0,0 +1,7 @@
export {}
declare global {
interface Element {
scrollIntoViewIfNeeded(opt_center?: boolean): void;
}
}