Virtual whiteboard for sketching hand-drawn like diagrams
feat: reopen library menu on import from file (#3383)
Thang Vu67289ef4ce7e
diff --git a/src/components/App.tsx b/src/components/App.tsxindex 8147d340b0..14df48cc05 100644--- a/src/components/App.tsx+++ b/src/components/App.tsx@@ -3624,7 +3624,9 @@ class App extends React.Component<AppProps, AppState> {) {Library.importLibrary(file).then(() => {+ // Close and then open to get the libraries updatedthis.setState({ isLibraryOpen: false });+ this.setState({ isLibraryOpen: true });}).catch((error) =>this.setState({ isLoading: false, errorMessage: error.message }),diff --git a/src/components/LayerUI.tsx b/src/components/LayerUI.tsxindex 0ad776815e..27c7f5aa9e 100644--- a/src/components/LayerUI.tsx+++ b/src/components/LayerUI.tsx@@ -142,9 +142,9 @@ const LibraryMenuItems = ({onClick={() => {importLibraryFromJSON().then(() => {- // Maybe we should close and open the menu so that the items get updated.- // But for now we just close the menu.+ // Close and then open to get the libraries updatedsetAppState({ isLibraryOpen: false });+ setAppState({ isLibraryOpen: true });}).catch(muteFSAbortError).catch((error) => {diff --git a/src/data/json.ts b/src/data/json.tsindex 4ecaccb3d2..59ac5eb3ed 100644--- a/src/data/json.ts+++ b/src/data/json.ts@@ -116,5 +116,5 @@ export const importLibraryFromJSON = async () => {extensions: [".json", ".excalidrawlib"],*/});- Library.importLibrary(blob);+ await Library.importLibrary(blob);};