Skip to content

Commit 4f69224

Browse files
Merge pull request #438 from lukecotter/bug-database-ui-jumping-on-group-expand
bug: database UI jumping on group expand
2 parents 12eb65c + c317666 commit 4f69224

3 files changed

Lines changed: 40 additions & 43 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1111

1212
- Call Tree Show Details not showing and hiding correctly ([#433][#433])
1313
- Infinite loading screen if file can not be found ([#435][#435])
14+
- Many cases of UI jumping in the Database view when rows and groups are clicked ([#434][#434])
1415

1516
## [1.10.1] - 2023-10-26
1617

@@ -275,6 +276,7 @@ Skipped due to adopting odd numbering for pre releases and even number for relea
275276

276277
<!-- v1.10.2 -->
277278

279+
[#434]: https://github.com/certinia/debug-log-analyzer/issues/434
278280
[#435]: https://github.com/certinia/debug-log-analyzer/issues/435
279281
[#433]: https://github.com/certinia/debug-log-analyzer/issues/433
280282

log-viewer/modules/database-view/DatabaseView.scss

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,5 @@
11
@import '../datagrid/style/DataGrid.scss';
22

3-
#db-container {
4-
overflow: scroll;
5-
}
6-
#db-dml-table,
7-
#db-soql-table {
8-
margin-bottom: 1rem;
9-
height: 100%;
10-
}
113
.row__details-container {
124
padding: 4px 0px 4px 0px;
135
background-color: var(--vscode-editorHoverWidget-background);

log-viewer/modules/database-view/DatabaseView.ts

Lines changed: 38 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,9 @@ export class DatabaseView extends LitElement {
9595
width: 100%;
9696
min-height: 0%;
9797
min-width: 0%;
98+
margin-bottom: 1rem;
99+
display: flex;
100+
flex-direction: column;
98101
}
99102
`,
100103
];
@@ -320,15 +323,13 @@ function renderDMLTable(dmlTableContainer: HTMLElement, dmlLines: DMLBeginLine[]
320323
}
321324
});
322325

323-
dmlTable.on('groupVisibilityChanged', (group: GroupComponent, visible: boolean) => {
324-
const firstRow = visible ? group.getRows()[0] : group.getRows()[0].getPrevRow();
325-
if (firstRow) {
326-
// @ts-expect-error it has 2 params
327-
firstRow.scrollTo('center', true).then(() => {
328-
firstRow
329-
.getElement()
330-
.scrollIntoView({ behavior: 'auto', block: 'center', inline: 'start' });
331-
});
326+
dmlTable.on('groupVisibilityChanged', (group: GroupComponent, _visible: boolean) => {
327+
const groupToFocus = group.getElement() ? group : findGroup(soqlTable, group.getKey());
328+
329+
if (groupToFocus) {
330+
groupToFocus
331+
.getElement()
332+
.scrollIntoView({ behavior: 'instant', block: 'center', inline: 'start' });
332333
}
333334
});
334335

@@ -337,18 +338,13 @@ function renderDMLTable(dmlTableContainer: HTMLElement, dmlLines: DMLBeginLine[]
337338
if (!(data.timestamp && data.dml)) {
338339
return;
339340
}
340-
const origRowHeight = row.getElement().offsetHeight;
341341

342+
const origRowHeight = row.getElement().offsetHeight;
342343
row.treeToggle();
343-
row.getCell('soql').getElement().style.height = origRowHeight + 'px';
344+
row.getCell('dml').getElement().style.height = origRowHeight + 'px';
344345

345-
const nextRow = row.getNextRow() || row.getTreeChildren()[0];
346-
if (nextRow) {
347-
// @ts-expect-error it has 2 params
348-
nextRow.scrollTo('center', true).then(() => {
349-
nextRow.getElement().scrollIntoView({ behavior: 'auto', block: 'center', inline: 'start' });
350-
});
351-
}
346+
row &&
347+
row.getElement().scrollIntoView({ behavior: 'instant', block: 'center', inline: 'start' });
352348
});
353349
}
354350

@@ -598,15 +594,13 @@ function renderSOQLTable(soqlTableContainer: HTMLElement, soqlLines: SOQLExecute
598594
}
599595
});
600596

601-
soqlTable.on('groupVisibilityChanged', (group: GroupComponent, visible: boolean) => {
602-
const firstRow = visible ? group.getRows()[0] : group.getRows()[0].getPrevRow();
603-
if (firstRow) {
604-
// @ts-expect-error it has 2 params
605-
firstRow.scrollTo('center', true).then(() => {
606-
firstRow
607-
.getElement()
608-
.scrollIntoView({ behavior: 'auto', block: 'center', inline: 'start' });
609-
});
597+
soqlTable.on('groupVisibilityChanged', (group: GroupComponent, _visible: boolean) => {
598+
const groupToFocus = group.getElement() ? group : findGroup(soqlTable, group.getKey());
599+
600+
if (groupToFocus) {
601+
groupToFocus
602+
.getElement()
603+
.scrollIntoView({ behavior: 'instant', block: 'center', inline: 'start' });
610604
}
611605
});
612606

@@ -617,17 +611,11 @@ function renderSOQLTable(soqlTableContainer: HTMLElement, soqlLines: SOQLExecute
617611
}
618612

619613
const origRowHeight = row.getElement().offsetHeight;
620-
621614
row.treeToggle();
622615
row.getCell('soql').getElement().style.height = origRowHeight + 'px';
623616

624-
const nextRow = row.getNextRow() || row.getTreeChildren()[0];
625-
if (nextRow) {
626-
// @ts-expect-error it has 2 params
627-
nextRow.scrollTo('center', true).then(() => {
628-
nextRow.getElement().scrollIntoView({ behavior: 'auto', block: 'center', inline: 'start' });
629-
});
630-
}
617+
row &&
618+
row.getElement().scrollIntoView({ behavior: 'instant', block: 'center', inline: 'start' });
631619
});
632620
}
633621

@@ -689,3 +677,18 @@ function downlodEncoder(defaultFileName: string) {
689677
return new Blob([fileContents], { type: mimeType });
690678
};
691679
}
680+
681+
function findGroup(table: Tabulator, groupKey: string): GroupComponent | null {
682+
let foundGroup = null;
683+
const groups = soqlTable.getGroups();
684+
let len = groups?.length - 1 || 0;
685+
while (len >= 0 && !foundGroup) {
686+
const toSearch = groups[len];
687+
if (toSearch.getKey() === groupKey) {
688+
foundGroup = toSearch;
689+
break;
690+
}
691+
len--;
692+
}
693+
return foundGroup;
694+
}

0 commit comments

Comments
 (0)