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

Centering overlay when scroll to it

Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
This commit is contained in:
Alex Andreev 2020-10-21 14:09:24 +03:00
parent 5c084b8557
commit f8548d6ec4
3 changed files with 7 additions and 6 deletions

View File

@ -118,8 +118,8 @@ export class PodLogs extends React.Component<Props> {
@autobind() @autobind()
toOverlay() { toOverlay() {
const { activeOverlayLine } = searchStore; const { activeOverlayLine } = searchStore;
if (!this.virtualListRef.current || activeOverlayLine == -1) return; if (!this.virtualListRef.current || activeOverlayLine === undefined) return;
this.virtualListRef.current.scrollToItem(activeOverlayLine); this.virtualListRef.current.scrollToItem(activeOverlayLine, "center");
} }
/** /**

View File

@ -106,9 +106,10 @@ export class SearchStore {
return value.replace( /[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&" ); return value.replace( /[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&" );
} }
@action
reset() { reset() {
this.searchQuery = ""; this.searchQuery = "";
this.activeOverlayIndex = -1 this.activeOverlayIndex = -1;
} }
} }

View File

@ -4,7 +4,7 @@ import "./virtual-list.scss";
import React, { Component } from "react"; import React, { Component } from "react";
import { observer } from "mobx-react"; import { observer } from "mobx-react";
import { ListChildComponentProps, VariableSizeList } from "react-window"; import { Align, ListChildComponentProps, VariableSizeList } from "react-window";
import { cssNames, noop } from "../../utils"; import { cssNames, noop } from "../../utils";
import { TableRowProps } from "../table/table-row"; import { TableRowProps } from "../table/table-row";
import { ItemObject } from "../../item.store"; import { ItemObject } from "../../item.store";
@ -83,8 +83,8 @@ export class VirtualList extends Component<Props, State> {
this.listRef.current.scrollToItem(index, "start"); this.listRef.current.scrollToItem(index, "start");
}) })
scrollToItem = (index: number) => { scrollToItem = (index: number, align: Align) => {
this.listRef.current.scrollToItem(index) this.listRef.current.scrollToItem(index, align)
} }
render() { render() {