Fix search resetting (#508)
This commit is contained in:
parent
68d492a855
commit
b45c1e7fd0
|
@ -14,21 +14,17 @@ type Props = {
|
|||
}
|
||||
|
||||
const ViewHeaderSearch = (props: Props) => {
|
||||
const {boardTree} = props
|
||||
const {boardTree, setSearchText} = props
|
||||
const intl = useIntl()
|
||||
|
||||
const searchFieldRef = useRef<{focus(selectAll?: boolean): void}>(null)
|
||||
const [isSearching, setIsSearching] = useState(Boolean(props.boardTree.getSearchText()))
|
||||
const [isSearching, setIsSearching] = useState(Boolean(boardTree.getSearchText()))
|
||||
const [searchValue, setSearchValue] = useState(boardTree.getSearchText())
|
||||
|
||||
useEffect(() => {
|
||||
searchFieldRef.current?.focus()
|
||||
}, [isSearching])
|
||||
|
||||
useEffect(() => {
|
||||
setSearchValue(boardTree.getSearchText())
|
||||
}, [boardTree])
|
||||
|
||||
useHotkeys('ctrl+shift+f,cmd+shift+f', () => {
|
||||
setIsSearching(true)
|
||||
searchFieldRef.current?.focus(true)
|
||||
|
@ -44,13 +40,13 @@ const ViewHeaderSearch = (props: Props) => {
|
|||
onCancel={() => {
|
||||
setSearchValue('')
|
||||
setIsSearching(false)
|
||||
props.setSearchText('')
|
||||
setSearchText('')
|
||||
}}
|
||||
onSave={() => {
|
||||
if (searchValue === '') {
|
||||
setIsSearching(false)
|
||||
}
|
||||
props.setSearchText(searchValue)
|
||||
setSearchText(searchValue)
|
||||
}}
|
||||
/>
|
||||
)
|
||||
|
|
|
@ -77,6 +77,7 @@ class MutableBoardTree implements BoardTree {
|
|||
}
|
||||
const rawBlocks = OctoUtils.mergeBlocks(boardTree.allBlocks, relevantBlocks)
|
||||
const newBoardTree = this.buildTree(boardTree.board.id, rawBlocks)
|
||||
newBoardTree?.setSearchText(boardTree.getSearchText())
|
||||
if (newBoardTree && boardTree.activeView) {
|
||||
newBoardTree.setActiveView(boardTree.activeView.id)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user