mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
fix: excalidrawAPI.toggleSidebar
not switching between tabs correctly (#7821)
This commit is contained in:
parent
7949aa1f1c
commit
65bc500598
3 changed files with 97 additions and 5 deletions
|
@ -3684,17 +3684,29 @@ class App extends React.Component<AppProps, AppState> {
|
|||
tab,
|
||||
force,
|
||||
}: {
|
||||
name: SidebarName;
|
||||
name: SidebarName | null;
|
||||
tab?: SidebarTabName;
|
||||
force?: boolean;
|
||||
}): boolean => {
|
||||
let nextName;
|
||||
if (force === undefined) {
|
||||
nextName = this.state.openSidebar?.name === name ? null : name;
|
||||
nextName =
|
||||
this.state.openSidebar?.name === name &&
|
||||
this.state.openSidebar?.tab === tab
|
||||
? null
|
||||
: name;
|
||||
} else {
|
||||
nextName = force ? name : null;
|
||||
}
|
||||
this.setState({ openSidebar: nextName ? { name: nextName, tab } : null });
|
||||
|
||||
const nextState: AppState["openSidebar"] = nextName
|
||||
? { name: nextName }
|
||||
: null;
|
||||
if (nextState && tab) {
|
||||
nextState.tab = tab;
|
||||
}
|
||||
|
||||
this.setState({ openSidebar: nextState });
|
||||
|
||||
return !!nextName;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue