Skip to content

Commit

Permalink
ensure all subtools have the correct value for has_suboptions (#2605)
Browse files Browse the repository at this point in the history
  • Loading branch information
kecnry authored Dec 11, 2023
1 parent 0d3d71e commit 0673de8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
2 changes: 2 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ Bug Fixes
- Fix image layer visibility toggle in plot options. [#2595]


- Fixes viewer toolbar items losing ability to bring up right-click menu. [#2605]

Cubeviz
^^^^^^^

Expand Down
12 changes: 7 additions & 5 deletions jdaviz/components/toolbar_nested.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ def _update_tool_visibilities(self):
for menu_ind in range(self._max_menu_ind):
has_primary = False
n_visible = 0
primary_id = None
if self.active_tool_id:
current_primary_active = self.tools_data[self.active_tool_id]['menu_ind'] == menu_ind # noqa
else:
Expand Down Expand Up @@ -116,15 +115,18 @@ def _update_tool_visibilities(self):
primary = visible and not has_primary

if primary:
primary_id = tool_id
has_primary = True

self.tools_data[tool_id] = {**info,
'primary': primary,
'visible': visible}
if primary_id:
self.tools_data[primary_id] = {**self.tools_data[primary_id],
'has_suboptions': n_visible > 1}

# update has_suboptions for all entries in this menu
for tool_id, info in self.tools_data.items():
if info['menu_ind'] != menu_ind:
continue
self.tools_data[tool_id] = {**self.tools_data[tool_id],
'has_suboptions': n_visible > 1}

# mutation to dictionary needs to be manually sent to update the UI
self.send_state("tools_data")
Expand Down

0 comments on commit 0673de8

Please sign in to comment.