Skip to content

Commit c6b3f4c

Browse files
committed
Wow
1 parent 0d3c2c2 commit c6b3f4c

File tree

3 files changed

+40
-36
lines changed

3 files changed

+40
-36
lines changed

packages/core/ui/CascadingMenu.tsx

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@ import { createContext, useContext, useMemo, useState } from 'react'
55
import ChevronRight from '@mui/icons-material/ChevronRight'
66
import HelpOutline from '@mui/icons-material/HelpOutline'
77
import {
8-
Dialog,
98
DialogContent,
10-
DialogTitle,
119
Divider,
1210
IconButton,
1311
ListItemIcon,
@@ -17,6 +15,7 @@ import {
1715
MenuItem,
1816
} from '@mui/material'
1917

18+
import Dialog from './Dialog'
2019
import HoverMenu from './HoverMenu'
2120
import { MenuItemEndDecoration } from './Menu'
2221
import { bindFocus, bindHover, bindMenu, usePopupState } from './hooks'
@@ -41,18 +40,29 @@ function HelpIconButton({ helpText }: { helpText: string }) {
4140
setHelpDialogOpen(true)
4241
}
4342

43+
const handleClose = (event: React.MouseEvent | React.KeyboardEvent) => {
44+
// Prevent backdrop click from propagating to menu item
45+
event.stopPropagation()
46+
setHelpDialogOpen(false)
47+
}
48+
4449
return (
4550
<>
4651
<IconButton
4752
size="small"
4853
onClick={handleHelpClick}
49-
onMouseDown={e => e.stopPropagation()}
5054
style={{ marginLeft: 4, padding: 4 }}
5155
>
5256
<HelpOutline fontSize="small" />
5357
</IconButton>
54-
<Dialog open={helpDialogOpen} onClose={() => setHelpDialogOpen(false)}>
55-
<DialogTitle>Help</DialogTitle>
58+
<Dialog
59+
open={helpDialogOpen}
60+
onClose={handleClose}
61+
title="Help"
62+
onClick={e => {
63+
e.stopPropagation()
64+
}}
65+
>
5666
<DialogContent>{helpText}</DialogContent>
5767
</Dialog>
5868
</>
@@ -243,9 +253,6 @@ function CascadingMenuList({
243253
onMenuItemClick: Function
244254
}) {
245255
const hasIcon = menuItems.some(m => 'icon' in m && m.icon)
246-
const hasCheckboxOrRadio = menuItems.some(
247-
m => m.type === 'checkbox' || m.type === 'radio',
248-
)
249256
const hasCheckboxOrRadioWithHelp = menuItems.some(
250257
m =>
251258
(m.type === 'checkbox' || m.type === 'radio') &&

plugins/data-management/src/HierarchicalTrackSelectorWidget/components/tree/TrackCategory.tsx

Lines changed: 24 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { useState } from 'react'
22

3-
import JBrowseMenu from '@jbrowse/core/ui/Menu'
3+
import { CascadingMenuButton } from '@jbrowse/core/ui'
44
import ArrowDropDownIcon from '@mui/icons-material/ArrowDropDown'
55
import ArrowRightIcon from '@mui/icons-material/ArrowRight'
66
import MoreHorizIcon from '@mui/icons-material/MoreHoriz'
7-
import { IconButton, Typography } from '@mui/material'
7+
import { Typography } from '@mui/material'
88
import { makeStyles } from 'tss-react/mui'
99

1010
import { getAllChildren, treeToMap } from '../util'
@@ -47,7 +47,7 @@ export default function Category({
4747
data: NodeData
4848
}) {
4949
const { classes } = useStyles()
50-
const [menuEl, setMenuEl] = useState<HTMLElement | null>(null)
50+
const [menuOpen, setMenuOpen] = useState(false)
5151
const { menuItems = [], name, model, id, tree } = data
5252

5353
const currentNode = treeToMap(tree).get(id)
@@ -58,7 +58,7 @@ export default function Category({
5858
<div
5959
className={classes.accordionText}
6060
onClick={() => {
61-
if (!menuEl) {
61+
if (!menuOpen) {
6262
data.toggleCollapse(id)
6363
setOpen(!isOpen)
6464
}
@@ -67,33 +67,25 @@ export default function Category({
6767
<Typography data-testid={`htsCategory-${name}`}>
6868
{isOpen ? <ArrowDropDownIcon /> : <ArrowRightIcon />}
6969
{name}
70-
<IconButton
71-
onClick={event => {
72-
setMenuEl(event.currentTarget)
73-
event.stopPropagation()
74-
}}
75-
className={classes.contrastColor}
76-
>
77-
<MoreHorizIcon />
78-
</IconButton>
79-
</Typography>
80-
{menuEl ? (
81-
<JBrowseMenu
82-
anchorEl={menuEl}
70+
<CascadingMenuButton
8371
menuItems={[
8472
{
8573
label: 'Add to selection',
8674
onClick: () => {
8775
const r = treeToMap(tree).get(id)
8876
model.addToSelection(getAllChildren(r))
8977
},
78+
helpText:
79+
'Add all tracks in this category to the current selection. This allows you to perform bulk operations on multiple tracks at once, such as configuring settings or exporting track configurations.',
9080
},
9181
{
9282
label: 'Remove from selection',
9383
onClick: () => {
9484
const r = treeToMap(tree).get(id)
9585
model.removeFromSelection(getAllChildren(r))
9686
},
87+
helpText:
88+
'Remove all tracks in this category from the current selection. Use this to deselect tracks that were previously added to your selection.',
9789
},
9890
{
9991
label: 'Show all',
@@ -104,6 +96,8 @@ export default function Category({
10496
}
10597
}
10698
},
99+
helpText:
100+
'Display all tracks in this category on the current view. This is useful when you want to visualize multiple related tracks simultaneously to compare their data.',
107101
},
108102
{
109103
label: 'Hide all',
@@ -114,6 +108,8 @@ export default function Category({
114108
}
115109
}
116110
},
111+
helpText:
112+
'Hide all tracks in this category from the current view. This helps declutter your view by removing tracks you are not currently analyzing.',
117113
},
118114
...(hasSubcategories
119115
? [
@@ -127,6 +123,8 @@ export default function Category({
127123
}
128124
}
129125
},
126+
helpText:
127+
'Collapse all nested subcategories within this category. This provides a cleaner, more compact view of the track hierarchy by hiding the detailed contents of subcategories.',
130128
},
131129
{
132130
label: 'Expand all subcategories',
@@ -138,21 +136,20 @@ export default function Category({
138136
}
139137
}
140138
},
139+
helpText:
140+
'Expand all nested subcategories within this category. This reveals all tracks and subcategories at once, making it easier to browse and select tracks from the entire hierarchy.',
141141
},
142142
]
143143
: []),
144144
...menuItems,
145145
]}
146-
onMenuItemClick={(_event, callback) => {
147-
callback()
148-
setMenuEl(null)
149-
}}
150-
open={Boolean(menuEl)}
151-
onClose={() => {
152-
setMenuEl(null)
153-
}}
154-
/>
155-
) : null}
146+
className={classes.contrastColor}
147+
stopPropagation
148+
setOpen={setMenuOpen}
149+
>
150+
<MoreHorizIcon />
151+
</CascadingMenuButton>
152+
</Typography>
156153
</div>
157154
)
158155
}

plugins/linear-comparative-view/src/LinearSyntenyView/model.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import { lazy } from 'react'
33
import { getSession } from '@jbrowse/core/util'
44
import CropFreeIcon from '@mui/icons-material/CropFree'
55
import LinkIcon from '@mui/icons-material/Link'
6-
import ShuffleIcon from '@mui/icons-material/Shuffle'
76
import PhotoCameraIcon from '@mui/icons-material/PhotoCamera'
7+
import ShuffleIcon from '@mui/icons-material/Shuffle'
88
import VisibilityIcon from '@mui/icons-material/Visibility'
99
import { saveAs } from 'file-saver'
1010
import { observable, transaction } from 'mobx'

0 commit comments

Comments
 (0)