fix: prevent resetting node state when toggle search mode but search input is empty

fix #217
This commit is contained in:
EnixCoda 2022-03-20 22:41:28 +08:00
parent 5efbf8354d
commit dbdc3828ac
2 changed files with 3 additions and 1 deletions

View file

@ -48,7 +48,8 @@ export function SearchBar({ onSearch, onFocus, value }: Props) {
configs.onChange({
searchMode: newMode,
})
onSearch(value, newMode)
// Skip search if no input to prevent resetting folder expansions
if (value) onSearch(value, newMode)
}}
aria-label={toggleButtonDescription}
>

View file

@ -322,6 +322,7 @@ class FlattenLayer extends CompressLayer {
this.expandedNodes.clear()
if (restoreExpandedFolders) {
this.backupExpandedNodes.forEach(path => this.expandedNodes.add(path))
this.backupExpandedNodes.clear()
}
}
}