Skip to content

Commit

Permalink
Fixes bug on URL highlight param in which refName aliases were not wo…
Browse files Browse the repository at this point in the history
…rking (#4275)
  • Loading branch information
carolinebridge authored Mar 8, 2024
1 parent 67d5877 commit 72d6402
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,16 @@ export default (pluginManager: PluginManager) => {
view.setHideHeader(!nav)
}
if (highlight !== undefined) {
const location = parseLocString(highlight, refName =>
const parsedLocString = parseLocString(highlight, refName =>
isValidRefName(refName, assembly),
) as Required<ParsedLocString>

const location = {
...parsedLocString,
assemblyName: assembly,
}

if (location?.start !== undefined && location?.end !== undefined) {
location.assemblyName = assembly
view.setHighlight(location)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ const Highlight = observer(function Highlight({ model }: { model: LGV }) {
const color = useTheme().palette.quaternary?.main ?? 'goldenrod'

const session = getSession(model) as SessionWithWidgets
const { assemblyManager } = session

const dismissHighlight = () => {
model.setHighlight(undefined)
Expand Down Expand Up @@ -95,7 +96,14 @@ const Highlight = observer(function Highlight({ model }: { model: LGV }) {
: undefined
}

const h = mapCoords(model.highlight)
const asm = assemblyManager.get(model.highlight?.assemblyName)

const h = mapCoords({
...model.highlight,
refName:
asm?.getCanonicalRefName(model.highlight.refName) ??
model.highlight.refName,
})

return (
<>
Expand All @@ -108,7 +116,11 @@ const Highlight = observer(function Highlight({ model }: { model: LGV }) {
}}
>
<Tooltip title={'Highlighted from URL parameter'} arrow>
<IconButton ref={anchorEl} onClick={() => setOpen(true)}>
<IconButton
ref={anchorEl}
onClick={() => setOpen(true)}
style={{ zIndex: 4 }}
>
<LinkIcon
fontSize="small"
sx={{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@ import React from 'react'
import { observer } from 'mobx-react'
import { makeStyles } from 'tss-react/mui'
import { colord } from '@jbrowse/core/util/colord'
import { ParsedLocString } from '@jbrowse/core/util'
import {
ParsedLocString,
SessionWithWidgets,
getSession,
} from '@jbrowse/core/util'
import { Base1DViewModel } from '@jbrowse/core/util/Base1DViewModel'

// locals
Expand Down Expand Up @@ -32,6 +36,9 @@ const OverviewHighlight = observer(function OverviewHighlight({
const { classes } = useStyles()
const { cytobandOffset } = model

const session = getSession(model) as SessionWithWidgets
const { assemblyManager } = session

// coords
const mapCoords = (r: Required<ParsedLocString>) => {
const s = overview.bpToPx({
Expand All @@ -56,7 +63,14 @@ const OverviewHighlight = observer(function OverviewHighlight({
return null
}

const h = mapCoords(model.highlight)
const asm = assemblyManager.get(model.highlight?.assemblyName)

const h = mapCoords({
...model.highlight,
refName:
asm?.getCanonicalRefName(model.highlight.refName) ??
model.highlight.refName,
})

return (
<>
Expand Down

0 comments on commit 72d6402

Please sign in to comment.