fix: disallow expand on error

This commit is contained in:
EnixCoda 2023-01-05 18:38:04 +08:00
parent 4982b9a1ca
commit a1853ec3d2

View file

@ -278,18 +278,21 @@ function useCollapseOnNoPermissionWhenTokenHasBeenSet(
function useShouldExpand() {
const getDerivedExpansion = useGetDerivedExpansion()
const error = useLoadedContext(SideBarErrorContext).value
const [shouldExpand, setShouldExpand] = React.useState(getDerivedExpansion)
const toggleShowSideBar = React.useCallback(
() => setShouldExpand(show => !show),
[setShouldExpand],
)
useSaveExpandStateOnToggle(shouldExpand)
useUpdateBodyIndentOnStateUpdate(shouldExpand)
const $shouldExpand = error ? false : shouldExpand
useSaveExpandStateOnToggle($shouldExpand)
useUpdateBodyIndentOnStateUpdate($shouldExpand)
useUpdateBodyIndentAfterRedirect(setShouldExpand)
useCollapseOnNoPermissionWhenTokenHasBeenSet(setShouldExpand)
return [shouldExpand, setShouldExpand, toggleShowSideBar] as const
return [$shouldExpand, setShouldExpand, toggleShowSideBar] as const
}
function useShowSidebarKeyboard(