diff --git a/packages/core/ui/AssemblySelector.tsx b/packages/core/ui/AssemblySelector.tsx index 52e3fda7f7..6e39079bc4 100644 --- a/packages/core/ui/AssemblySelector.tsx +++ b/packages/core/ui/AssemblySelector.tsx @@ -60,7 +60,7 @@ const AssemblySelector = observer( label="Assembly" variant="outlined" helperText={error || 'Select assembly to view'} - value={error ? '' : selection} + value={selection} inputProps={{ 'data-testid': 'assembly-selector' }} onChange={event => setLastSelected(event.target.value)} error={!!error} diff --git a/plugins/dotplot-view/src/DotplotView/model.ts b/plugins/dotplot-view/src/DotplotView/model.ts index b3458cc0ff..db31d02db2 100644 --- a/plugins/dotplot-view/src/DotplotView/model.ts +++ b/plugins/dotplot-view/src/DotplotView/model.ts @@ -290,6 +290,7 @@ export default function stateModelFactory(pm: PluginManager) { self.hview.setDisplayedRegions([]) self.vview.setDisplayedRegions([]) self.assemblyNames = cast([]) + self.tracks.clear() }, /** * #action diff --git a/plugins/linear-genome-view/src/LinearGenomeView/components/ImportForm.tsx b/plugins/linear-genome-view/src/LinearGenomeView/components/ImportForm.tsx index 1a3b39b623..1235add51f 100644 --- a/plugins/linear-genome-view/src/LinearGenomeView/components/ImportForm.tsx +++ b/plugins/linear-genome-view/src/LinearGenomeView/components/ImportForm.tsx @@ -1,8 +1,14 @@ -import React, { useState, lazy } from 'react' +import React, { useState, useEffect, lazy } from 'react' import { makeStyles } from 'tss-react/mui' import { observer } from 'mobx-react' import { getSession } from '@jbrowse/core/util' -import { Button, CircularProgress, Container, Grid } from '@mui/material' +import { + Button, + CircularProgress, + FormControl, + Container, + Grid, +} from '@mui/material' import { ErrorMessage, AssemblySelector } from '@jbrowse/core/ui' import BaseResult from '@jbrowse/core/TextSearch/BaseResults' import CloseIcon from '@mui/icons-material/Close' @@ -10,7 +16,7 @@ import CloseIcon from '@mui/icons-material/Close' // locals import RefNameAutocomplete from './RefNameAutocomplete' import { fetchResults, splitLast } from './util' -import { LinearGenomeViewModel, WIDGET_HEIGHT } from '..' +import { LinearGenomeViewModel } from '..' const SearchResultsDialog = lazy(() => import('./SearchResultsDialog')) const useStyles = makeStyles()(theme => ({ @@ -44,8 +50,14 @@ const ImportForm = observer(({ model }: { model: LGV }) => { : 'No configured assemblies' const regions = assembly?.regions || [] const err = assemblyError || importError - const [myVal, setValue] = useState('') - const value = myVal || regions[0]?.refName + const [value, setValue] = useState('') + const r0 = regions[0]?.refName + + // useEffect resets to an "initial state" of displaying first region from assembly + // after assembly change + useEffect(() => { + setValue(r0) + }, [r0]) function navToOption(option: BaseResult) { const location = option.getLocation() @@ -100,8 +112,6 @@ const ImportForm = observer(({ model }: { model: LGV }) => { } } - const height = WIDGET_HEIGHT + 5 - // implementation notes: // having this wrapped in a form allows intuitive use of enter key to submit return ( @@ -124,47 +134,49 @@ const ImportForm = observer(({ model }: { model: LGV }) => { alignItems="center" > - { - setImportError('') - setSelectedAsm(val) - setValue('') - }} - session={session} - selected={selectedAsm} - InputProps={{ style: { height } }} - /> + + { + setImportError('') + setSelectedAsm(val) + setValue('') + }} + session={session} + selected={selectedAsm} + /> + {selectedAsm ? ( err ? ( ) : value ? ( - - fetchResults({ - queryString, - assembly, - textSearchManager, - rankSearchResults, - searchScope, - }) - } - model={model} - assemblyName={assemblyError ? undefined : selectedAsm} - value={value} - // note: minWidth 270 accomodates full width of helperText - minWidth={270} - onChange={str => setValue(str)} - onSelect={val => setOption(val)} - TextFieldProps={{ - variant: 'outlined', - helperText: - 'Enter sequence name, feature name, or location', - style: { minWidth: '175px' }, - InputProps: { style: { height } }, - }} - /> + + + fetchResults({ + queryString, + assembly, + textSearchManager, + rankSearchResults, + searchScope, + }) + } + model={model} + assemblyName={assemblyError ? undefined : selectedAsm} + value={value} + // note: minWidth 270 accomodates full width of helperText + minWidth={270} + onChange={str => setValue(str)} + onSelect={val => setOption(val)} + TextFieldProps={{ + variant: 'outlined', + helperText: + 'Enter sequence name, feature name, or location', + style: { minWidth: '175px' }, + }} + /> + ) : ( { ) : null} - - + + + + + +