Fix bug with SearchModal state
Ensures that SearchModal applies filters correctly so that modals invoked from extra positions only show extra weapons
This commit is contained in:
parent
3d7f0ab893
commit
f6816cf685
1 changed files with 29 additions and 2 deletions
|
|
@ -27,6 +27,7 @@ import type { SearchableObject, SearchableObjectArray } from '~types'
|
|||
import styles from './index.module.scss'
|
||||
import CrossIcon from '~public/icons/Cross.svg'
|
||||
import classNames from 'classnames'
|
||||
import useDidMountEffect from '~utils/useDidMountEffect'
|
||||
|
||||
interface Props extends DialogProps {
|
||||
send: (object: SearchableObject, position: number) => any
|
||||
|
|
@ -80,6 +81,23 @@ const SearchModal = (props: Props) => {
|
|||
if (props.open !== undefined) setOpen(props.open)
|
||||
})
|
||||
|
||||
useDidMountEffect(() => {
|
||||
// Only show extra or subaura objects if invoked from those positions
|
||||
if (extraPositions().includes(props.fromPosition)) {
|
||||
if (props.object === 'weapons') {
|
||||
setFilters({
|
||||
extra: true,
|
||||
...filters,
|
||||
})
|
||||
} else if (props.object === 'summons') {
|
||||
setFilters({
|
||||
subaura: true,
|
||||
...filters,
|
||||
})
|
||||
}
|
||||
}
|
||||
}, [open])
|
||||
|
||||
function inputChanged(event: React.ChangeEvent<HTMLInputElement>) {
|
||||
const text = event.target.value
|
||||
if (text.length) {
|
||||
|
|
@ -185,8 +203,17 @@ const SearchModal = (props: Props) => {
|
|||
|
||||
// Only show extra or subaura objects if invoked from those positions
|
||||
if (extraPositions().includes(props.fromPosition)) {
|
||||
if (props.object === 'weapons') filters.extra = true
|
||||
else if (props.object === 'summons') filters.subaura = true
|
||||
if (props.object === 'weapons') {
|
||||
setFilters({
|
||||
extra: true,
|
||||
...filters,
|
||||
})
|
||||
} else if (props.object === 'summons') {
|
||||
setFilters({
|
||||
subaura: true,
|
||||
...filters,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
setFilters(filters)
|
||||
|
|
|
|||
Loading…
Reference in a new issue