Skip to content

Commit

Permalink
Minimal fix
Browse files Browse the repository at this point in the history
  • Loading branch information
cmdcolin committed Aug 10, 2021
1 parent bd3b7b1 commit d5a2f28
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,11 @@ const Node = props => {
id,
name,
onChange,
toggleCollapse,
conf,
onMoreInfo,
} = data

const classes = useStyles()
const width = 10
const marginLeft = nestingLevel * width + (isLeaf ? width : 0)
Expand All @@ -131,7 +133,10 @@ const Node = props => {
))}
<div
className={!isLeaf ? classes.accordionCard : undefined}
onClick={() => setOpen(!isOpen)}
onClick={() => {
toggleCollapse(id)
setOpen(!isOpen)
}}
style={{
marginLeft,
whiteSpace: 'nowrap',
Expand Down Expand Up @@ -199,17 +204,18 @@ const getNodeData = (node, nestingLevel, extra) => {
// in jbrowse-web the toolbar is position="sticky" which means the autosizer
// includes the height of the toolbar, so we subtract the given offsets
const HierarchicalTree = observer(({ height, tree, model }) => {
const { filterText, view } = model
const treeRef = useRef(null)
const [info, setMoreInfo] = useState()
const session = getSession(model)
const { filterText } = model

const extra = useMemo(
() => ({
onChange: trackId => model.view.toggleTrack(trackId),
onChange: trackId => view.toggleTrack(trackId),
toggleCollapse: pathName => model.toggleCategory(pathName),
onMoreInfo: setMoreInfo,
}),
[model.view],
[view, model],
)
const treeWalker = useCallback(
function* treeWalker() {
Expand Down Expand Up @@ -540,14 +546,9 @@ const HierarchicalTrackSelector = observer(({ model, toolbarHeight = 0 }) => {
const [assemblyIdx, setAssemblyIdx] = useState(0)
const [headerHeight, setHeaderHeight] = useState(0)

const { assemblyNames } = model
const { assemblyNames, collapsed } = model
const assemblyName = assemblyNames[assemblyIdx]
if (!assemblyName) {
return null
}
const nodes = model.hierarchy(assemblyNames[assemblyIdx])

return (
return assemblyName ? (
<>
<HierarchicalTrackSelectorHeader
model={model}
Expand All @@ -556,12 +557,12 @@ const HierarchicalTrackSelector = observer(({ model, toolbarHeight = 0 }) => {
assemblyIdx={assemblyIdx}
/>
<AutoSizedHierarchicalTree
tree={nodes}
tree={model.hierarchy(assemblyName, collapsed)}
model={model}
offset={toolbarHeight + headerHeight}
/>
</>
)
) : null
})

export default HierarchicalTrackSelectorContainer
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export function generateHierarchy(model, trackConfigurations, collapsed) {
children: [],
name: category,
id,
state: { expanded: !collapsed.get(id) },
isOpenByDefault: !collapsed.get(id),
}
currLevel.children.push(n)
currLevel = n
Expand Down Expand Up @@ -90,7 +90,6 @@ export default pluginManager =>
view: types.safeReference(
pluginManager.pluggableMstType('view', 'stateModel'),
),
collapsedCategories: types.map(types.string, types.boolean),
})
.actions(self => ({
setView(view) {
Expand Down Expand Up @@ -188,11 +187,11 @@ export default pluginManager =>
})
},

hierarchy(assemblyName) {
hierarchy(assemblyName, collapsed) {
const hier = generateHierarchy(
self,
self.trackConfigurations(assemblyName),
self.collapsed,
collapsed,
)

const session = getSession(self)
Expand Down

0 comments on commit d5a2f28

Please sign in to comment.