mirror of
https://github.com/BoostIo/Boostnote
synced 2025-12-13 09:46:22 +00:00
Add collapsed state for storage
The root cause of this issue is that when the folder is clicked, the router pushed the path and the StorageItem component has been refreshed and isOpen has been reset - Add storing collapse state for storage - Add tests - Default as collapsed for fallback fix BoostIo/Boostnote#1979 BoostIo/Boostnote#1911
This commit is contained in:
@@ -21,8 +21,10 @@ class StorageItem extends React.Component {
|
||||
constructor (props) {
|
||||
super(props)
|
||||
|
||||
const { storage } = this.props
|
||||
|
||||
this.state = {
|
||||
isOpen: true
|
||||
isOpen: !!storage.isOpen
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,8 +70,18 @@ class StorageItem extends React.Component {
|
||||
}
|
||||
|
||||
handleToggleButtonClick (e) {
|
||||
const { storage, dispatch } = this.props
|
||||
const isOpen = !this.state.isOpen
|
||||
dataApi.toggleStorage(storage.key, isOpen)
|
||||
.then((storage) => {
|
||||
dispatch({
|
||||
type: 'EXPAND_STORAGE',
|
||||
storage: storage,
|
||||
isOpen: isOpen
|
||||
})
|
||||
})
|
||||
this.setState({
|
||||
isOpen: !this.state.isOpen
|
||||
isOpen: isOpen
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user