Skip to content

Fixed an issue in the Search Objects tool where selecting a node woul… #8851

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions web/pgadmin/browser/static/js/browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ define('pgadmin.browser', [
obj.Events.on('pgadmin:browser:tree:update', obj.onUpdateTreeNode.bind(obj));
obj.Events.on('pgadmin:browser:tree:refresh', obj.onRefreshTreeNodeReact.bind(obj));
obj.Events.on('pgadmin-browser:tree:loadfail', obj.onLoadFailNode.bind(obj));
obj.Events.on('pgadmin:browser:tree:disable_select', obj.disableTreeSelection.bind(obj));
obj.bind_beforeunload();

/* User UI activity */
Expand Down Expand Up @@ -1650,6 +1651,10 @@ define('pgadmin.browser', [

},

disableTreeSelection: function(_disable) {
pgBrowser.disable_tree_select = _disable;
Copy link
Contributor

@adityatoshniwal adityatoshniwal Jun 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think disable selection value should be internal to tree object which can internally check when calling .select. That way we will not need to add check at all the places.
Other than that, I don't think this is a good solution. You're disable select on search objects - kind of a hack and not solution. You're not fixing the root cause.

},

editor_shortcut_keys: {
// Autocomplete sql command
'Ctrl-Space': 'autocomplete',
Expand Down
6 changes: 3 additions & 3 deletions web/pgadmin/browser/static/js/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -784,12 +784,12 @@ define('pgadmin.browser.node', [

if (first_child._loaded) {
tree.open(first_child);
tree.select(first_child);
!pgBrowser['disable_tree_select'] && tree.select(first_child);
} else {
const openSoleItem = setInterval(() => {
if (first_child._loaded) {
tree.open(first_child);
tree.select(first_child);
!pgBrowser['disable_tree_select'] && tree.select(first_child);
clearSoleItemInterval();
}
}, 200);
Expand All @@ -800,7 +800,7 @@ define('pgadmin.browser.node', [

} else if(tree.children(item).length == 1) {
const first_child = tree.first(item);
tree.select(first_child);
!pgBrowser['disable_tree_select'] && tree.select(first_child);
}

pgBrowser.Events.trigger('pgadmin:browser:tree:update-tree-state', item);
Expand Down
4 changes: 4 additions & 0 deletions web/pgadmin/browser/templates/browser/js/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ define('pgadmin.browser.utils',
/* Enable server password exec command */
pgAdmin['enable_server_passexec_cmd'] = '{{enable_server_passexec_cmd}}';

/* Enable tree.select of all places by default */
pgBrowser['disable_tree_select'] = false;


// Define list of nodes on which Query tool option doesn't appears
let unsupported_nodes = pgAdmin.unsupported_nodes = [
'server_group', 'server', 'coll-tablespace', 'tablespace',
Expand Down
11 changes: 11 additions & 0 deletions web/pgadmin/static/js/helpers/Layout/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import PropTypes from 'prop-types';
import EventBus from '../EventBus';
import getApiInstance from '../../api_instance';
import url_for from 'sources/url_for';
import pgAdmin from 'sources/pgadmin';
import { PgIconButton } from '../../components/Buttons';
import CloseIcon from '@mui/icons-material/CloseRounded';
import gettext from 'sources/gettext';
Expand Down Expand Up @@ -192,6 +193,11 @@ export class LayoutDocker {
})],
}, null, 'float');
}
if (panelData?.id == 'id-search-objects') {
// Disable the tree.select from all other places as it is clashing with
// the tree.select() in tree.findNodeWithToggle() of Search objects module.
pgAdmin.Browser.Events.trigger('pgadmin:browser:tree:disable_select', true);
}
}

isTabOpen(panelId) {
Expand Down Expand Up @@ -342,6 +348,11 @@ function DialogClose({panelData}) {
<Box display="flex" alignItems="center">
<PgIconButton title={gettext('Close')} icon={<CloseIcon />} size="xs" noBorder onClick={()=>{
layoutDocker.close(panelData.activeId);
if (panelData?.activeId == 'id-search-objects') {
// Enable the tree.select of all other places after closing of Search Objects dialog as it
// is clashing with the tree.select() in tree.findNodeWithToggle() of Search objects module.
pgAdmin.Browser.Events.trigger('pgadmin:browser:tree:disable_select', false);
}
}} style={{marginRight: '-4px'}}/>
</Box>
);
Expand Down
2 changes: 1 addition & 1 deletion web/pgadmin/static/js/tree/pgadmin_tree_save_state.js
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ _.extend(pgBrowser.browserTreeState, {
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['disable_tree_select'] && pgBrowser.tree.select(item, true, 'center');
}
}
}
Expand Down
Loading