Logs: Fix scrolling with exploreScrollableLogsContainer feature flag (#70164)

correct scrolling with `exploreScrollableLogsContainer`
This commit is contained in:
Sven Grossmann 2023-06-19 13:15:22 +02:00 committed by GitHub
parent 271cdb4baa
commit 1a985c488c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -136,6 +136,7 @@ class UnthemedLogs extends PureComponent<Props, State> {
cancelFlippingTimer?: number; cancelFlippingTimer?: number;
topLogsRef = createRef<HTMLDivElement>(); topLogsRef = createRef<HTMLDivElement>();
logsVolumeEventBus: EventBus; logsVolumeEventBus: EventBus;
logsContainer = createRef<HTMLDivElement>();
state: State = { state: State = {
showLabels: store.getBool(SETTINGS_KEYS.showLabels, false), showLabels: store.getBool(SETTINGS_KEYS.showLabels, false),
@ -370,6 +371,17 @@ class UnthemedLogs extends PureComponent<Props, State> {
}; };
scrollIntoView = (element: HTMLElement) => { scrollIntoView = (element: HTMLElement) => {
if (config.featureToggles.exploreScrollableLogsContainer) {
this.scrollToTopLogs();
if (this.logsContainer.current) {
this.logsContainer.current.scroll({
behavior: 'smooth',
top: this.logsContainer.current.scrollTop + element.getBoundingClientRect().top - window.innerHeight / 2,
});
}
return;
}
const { scrollElement } = this.props; const { scrollElement } = this.props;
if (scrollElement) { if (scrollElement) {
@ -582,7 +594,7 @@ class UnthemedLogs extends PureComponent<Props, State> {
clearDetectedFields={this.clearDetectedFields} clearDetectedFields={this.clearDetectedFields}
/> />
<div className={styles.logsSection}> <div className={styles.logsSection}>
<div className={styles.logRows} data-testid="logRows"> <div className={styles.logRows} data-testid="logRows" ref={this.logsContainer}>
<LogRows <LogRows
logRows={logRows} logRows={logRows}
deduplicatedRows={dedupedRows} deduplicatedRows={dedupedRows}