mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
LogRow: ensure scrollIntoView is called only once with shortlinks (#72291)
This commit is contained in:
parent
b71117393b
commit
ec5650cc82
@ -66,6 +66,7 @@ describe('LogRow', () => {
|
|||||||
logRowUid: 'log-row-id',
|
logRowUid: 'log-row-id',
|
||||||
datasourceType: 'unknown',
|
datasourceType: 'unknown',
|
||||||
});
|
});
|
||||||
|
expect(scrollIntoView).toHaveBeenCalledTimes(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('highlights row with same permalink-id', () => {
|
it('highlights row with same permalink-id', () => {
|
||||||
@ -104,11 +105,18 @@ describe('LogRow', () => {
|
|||||||
expect(scrollIntoView).toHaveBeenCalled();
|
expect(scrollIntoView).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('not calls `scrollIntoView` if permalink does not match', () => {
|
it('does not call `scrollIntoView` if permalink does not match', () => {
|
||||||
const scrollIntoView = jest.fn();
|
const scrollIntoView = jest.fn();
|
||||||
setup({ permalinkedRowId: 'wrong-log-row-id', scrollIntoView });
|
setup({ permalinkedRowId: 'wrong-log-row-id', scrollIntoView });
|
||||||
expect(scrollIntoView).not.toHaveBeenCalled();
|
expect(scrollIntoView).not.toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('calls `scrollIntoView` once', async () => {
|
||||||
|
const scrollIntoView = jest.fn();
|
||||||
|
setup({ permalinkedRowId: 'log-row-id', scrollIntoView });
|
||||||
|
await userEvent.hover(screen.getByText('test123'));
|
||||||
|
expect(scrollIntoView).toHaveBeenCalledTimes(1);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should render the menu cell on mouse over', async () => {
|
it('should render the menu cell on mouse over', async () => {
|
||||||
|
@ -143,11 +143,11 @@ class UnThemedLogRow extends PureComponent<Props, State> {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// at this point this row is the permalinked row, so we need to scroll to it and highlight it if possible.
|
|
||||||
if (this.logLineRef.current && scrollIntoView) {
|
|
||||||
scrollIntoView(this.logLineRef.current);
|
|
||||||
}
|
|
||||||
if (!this.state.highlightBackround) {
|
if (!this.state.highlightBackround) {
|
||||||
|
// at this point this row is the permalinked row, so we need to scroll to it and highlight it if possible.
|
||||||
|
if (this.logLineRef.current && scrollIntoView) {
|
||||||
|
scrollIntoView(this.logLineRef.current);
|
||||||
|
}
|
||||||
reportInteraction('grafana_explore_logs_permalink_opened', {
|
reportInteraction('grafana_explore_logs_permalink_opened', {
|
||||||
datasourceType: row.datasourceType ?? 'unknown',
|
datasourceType: row.datasourceType ?? 'unknown',
|
||||||
logRowUid: row.uid,
|
logRowUid: row.uid,
|
||||||
|
Loading…
Reference in New Issue
Block a user