Ensure that the browser tree should auto scroll to the selected node when expanding the server node. #2174

This commit is contained in:
Nikhil Mohite 2022-11-07 10:54:58 +05:30 committed by GitHub
parent 5219c25189
commit c38face9fc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 3 deletions

View File

@ -49,6 +49,8 @@ _.extend(pgBrowser.browserTreeState, {
// Previous tree state
last_state: {},
is_selected: false,
// Current tree state
current_state: {},
@ -314,6 +316,7 @@ _.extend(pgBrowser.browserTreeState, {
}
// Select the previously selected item
!this.is_selected && pgBrowser.tree.ensureVisible(item, 'center');
this.select_tree_item(item);
},
@ -372,13 +375,14 @@ _.extend(pgBrowser.browserTreeState, {
treeHierarchy = pgBrowser.tree.getTreeNodeHierarchy(item),
tmpTreeData = treeData[treeHierarchy[this.parent]['_id']];
if (treeHierarchy.hasOwnProperty('server')) {
let selectedItem = treeHierarchy['server']['id'];
if (tmpTreeData && 'selected' in tmpTreeData && selectedItem in tmpTreeData['selected']) {
if (tmpTreeData['selected'][selectedItem] == data.id) {
this.is_selected = true;
pgBrowser.tree.select(item, true, 'center');
pgBrowser.tree.ensureVisible(item, 'center');
}
}
}

View File

@ -154,8 +154,8 @@ export class Tree {
await item.ensureLoaded();
}
async ensureVisible(item) {
await this.tree.ensureVisible(item);
async ensureVisible(item, align='auto') {
await this.tree.ensureVisible(item, align);
}
async openPath(item) {