diff --git a/packages/core/configuration/util.ts b/packages/core/configuration/util.ts index f42accafdc..642b5de9c2 100644 --- a/packages/core/configuration/util.ts +++ b/packages/core/configuration/util.ts @@ -93,10 +93,7 @@ export function readConfObject( ) { subConf = confObject.get(slotName) } - if (!subConf) { - return undefined - } - return readConfObject(subConf, newPath, args) + return subConf ? readConfObject(subConf, newPath, args) : undefined } return readConfObject(confObject, slotName, args) } diff --git a/packages/core/util/index.ts b/packages/core/util/index.ts index bc44ef4669..5bb7414091 100644 --- a/packages/core/util/index.ts +++ b/packages/core/util/index.ts @@ -504,21 +504,22 @@ function roundToNearestPointOne(num: number): number { */ export function bpToPx( bp: number, - region: { start: number; end: number; reversed?: boolean }, + { + reversed, + end = 0, + start = 0, + }: { start?: number; end?: number; reversed?: boolean }, bpPerPx: number, -): number { - if (region.reversed) { - return roundToNearestPointOne((region.end - bp) / bpPerPx) - } - return roundToNearestPointOne((bp - region.start) / bpPerPx) +) { + return roundToNearestPointOne((reversed ? end - bp : bp - start) / bpPerPx) } const oneEightyOverPi = 180.0 / Math.PI const piOverOneEighty = Math.PI / 180.0 -export function radToDeg(radians: number): number { +export function radToDeg(radians: number) { return (radians * oneEightyOverPi) % 360 } -export function degToRad(degrees: number): number { +export function degToRad(degrees: number) { return (degrees * piOverOneEighty) % (2 * Math.PI) } diff --git a/packages/core/util/simpleFeature.ts b/packages/core/util/simpleFeature.ts index 160b5a4d8b..8adb45363b 100644 --- a/packages/core/util/simpleFeature.ts +++ b/packages/core/util/simpleFeature.ts @@ -9,6 +9,7 @@ export interface Feature { get(name: 'refName'): string get(name: 'start'): number get(name: 'end'): number + get(name: 'subfeatures'): Feature[] | undefined // eslint-disable-next-line @typescript-eslint/no-explicit-any get(name: string): any diff --git a/plugins/linear-genome-view/src/BaseLinearDisplay/components/BaseLinearDisplay.tsx b/plugins/linear-genome-view/src/BaseLinearDisplay/components/BaseLinearDisplay.tsx index 5e0632781f..96ee3b13fc 100644 --- a/plugins/linear-genome-view/src/BaseLinearDisplay/components/BaseLinearDisplay.tsx +++ b/plugins/linear-genome-view/src/BaseLinearDisplay/components/BaseLinearDisplay.tsx @@ -1,8 +1,8 @@ import React, { useState, useRef, useMemo } from 'react' +import { observer } from 'mobx-react' import { Portal, alpha, useTheme, makeStyles } from '@material-ui/core' import { getConf } from '@jbrowse/core/configuration' import { Menu } from '@jbrowse/core/ui' -import { observer } from 'mobx-react' import { usePopper } from 'react-popper' // locals @@ -56,7 +56,6 @@ const Tooltip = observer( const classes = useStyles() const { featureUnderMouse } = model const [width, setWidth] = useState(0) - const [popperElt, setPopperElt] = useState(null) // must be memoized a la https://github.com/popperjs/react-popper/issues/391 @@ -111,7 +110,7 @@ const BaseLinearDisplay = observer( const classes = useStyles() const theme = useTheme() const ref = useRef(null) - const [clientRect, setClientRect] = useState() + const [clientRect, setClientRect] = useState() const [offsetMouseCoord, setOffsetMouseCoord] = useState([0, 0]) const [clientMouseCoord, setClientMouseCoord] = useState([0, 0]) const [contextCoord, setContextCoord] = useState() @@ -139,17 +138,15 @@ const BaseLinearDisplay = observer( } }} onMouseMove={event => { - if (ref.current) { - const rect = ref.current.getBoundingClientRect() - setOffsetMouseCoord([ - event.clientX - rect.left, - event.clientY - rect.top, - ]) - setClientMouseCoord([event.clientX, event.clientY]) - setClientRect(rect) + if (!ref.current) { + return } + const rect = ref.current.getBoundingClientRect() + const { left, top } = rect + setOffsetMouseCoord([event.clientX - left, event.clientY - top]) + setClientMouseCoord([event.clientX, event.clientY]) + setClientRect(rect) }} - role="presentation" > {DisplayMessageComponent ? ( diff --git a/plugins/linear-genome-view/src/LinearGenomeView/components/__snapshots__/LinearGenomeView.test.js.snap b/plugins/linear-genome-view/src/LinearGenomeView/components/__snapshots__/LinearGenomeView.test.js.snap index fe41b14ebc..25bd03a446 100644 --- a/plugins/linear-genome-view/src/LinearGenomeView/components/__snapshots__/LinearGenomeView.test.js.snap +++ b/plugins/linear-genome-view/src/LinearGenomeView/components/__snapshots__/LinearGenomeView.test.js.snap @@ -541,7 +541,6 @@ exports[` renders one track, one region 1`] = `