Fixed an issue in the Search Objects tool where selecting a node occasionally selected an incorrect node. #8675

pull/8945/head
Anil Sahoo 2025-07-10 15:37:31 +05:30 committed by GitHub
parent 60c8e5fe05
commit 0ebf78ca61
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 28 additions and 5 deletions

View File

@ -729,9 +729,19 @@ define('pgadmin.browser.node', [
_item.clear_cache.apply(_item);
}, 0);
}
pgBrowser.Events.trigger('pgadmin:browser:tree:expand-from-previous-tree-state',
item);
pgBrowser.Node.callbacks.change_server_background(item, data);
// Suppress added tree event being called during object search operations
// where tree.select clashes due to previous tree state restore
const suppressPath = pgBrowser.tree.suppressEventsForPath;
if (suppressPath) {
if (item.path === suppressPath) {
pgBrowser.tree.suppressEventsForPath = null;
} else {
return;
}
}
pgBrowser.Events.trigger('pgadmin:browser:tree:expand-from-previous-tree-state', item);
},
// Callback called - when a node is selected in browser tree.
selected: function(item, data) {
@ -777,6 +787,16 @@ define('pgadmin.browser.node', [
opened: function(item) {
let tree = pgBrowser.tree,
auto_expand = usePreferences.getState().getPreferences('browser', 'auto_expand_sole_children');
// Suppress opened tree event being called during object search operations
// where tree.select clashes due to only child of parent opens automatically.
const suppressPath = pgBrowser.tree.suppressEventsForPath;
if (suppressPath) {
if (item.path === suppressPath) {
pgBrowser.tree.suppressEventsForPath = null;
} else {
return;
}
}
if (auto_expand?.value && tree.children(item).length == 1) {
// Automatically expand the child node, if a treeview node has only a single child.

View File

@ -130,11 +130,10 @@ export class FileTreeItem extends React.Component<IItemRendererXProps & IItemRen
if (this.props.decorations) {
this.props.decorations.addChangeListener(this.forceUpdate);
}
this.setActiveFile(this.props.item);
this.setFileLoaded(this.props.item);
}
private readonly setActiveFile = async (FileOrDir): Promise<void> => {
private readonly setFileLoaded = async (FileOrDir): Promise<void> => {
this.props.changeDirectoryCount(FileOrDir.parent);
if(FileOrDir._loaded !== true) {
this.events.dispatch(FileTreeXEvent.onTreeEvents, window.event, 'added', FileOrDir);

View File

@ -84,6 +84,9 @@ export class Tree {
this.rootNode = manageTree.tempTree;
this.Nodes = pgBrowser ? pgBrowser.Nodes : pgAdmin.Browser.Nodes;
// Flag to suppress added and opened tree event being called during object search operations,
// tree.select of search object clashes with other tree.select.
this.suppressEventsForPath = null;
this.draggableTypes = {};
}

View File

@ -313,6 +313,7 @@ export default function SearchObjects({nodeData}) {
return false;
}
tree.suppressEventsForPath = '/browser/' + rowData.id_path.join('/');
setLoaderText(gettext('Locating...'));
tree.findNodeWithToggle(rowData.id_path)
.then((treeItem)=>{