Skip to content

Commit

Permalink
feat: smarter zooming when scrolling to match & only match on search/…
Browse files Browse the repository at this point in the history
…switch (excalidraw#8488)
  • Loading branch information
dwelle authored Sep 10, 2024
1 parent d107215 commit 72b7c93
Show file tree
Hide file tree
Showing 2 changed files with 127 additions and 82 deletions.
9 changes: 8 additions & 1 deletion excalidraw-app/data/LocalData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
get,
} from "idb-keyval";
import { clearAppStateForLocalStorage } from "../../packages/excalidraw/appState";
import { SEARCH_SIDEBAR } from "../../packages/excalidraw/constants";
import type { LibraryPersistedData } from "../../packages/excalidraw/data/library";
import type { ImportedDataState } from "../../packages/excalidraw/data/types";
import { clearElementsForLocalStorage } from "../../packages/excalidraw/element";
Expand Down Expand Up @@ -66,13 +67,19 @@ const saveDataStateToLocalStorage = (
appState: AppState,
) => {
try {
const _appState = clearAppStateForLocalStorage(appState);

if (_appState.openSidebar?.name === SEARCH_SIDEBAR.name) {
_appState.openSidebar = null;
}

localStorage.setItem(
STORAGE_KEYS.LOCAL_STORAGE_ELEMENTS,
JSON.stringify(clearElementsForLocalStorage(elements)),
);
localStorage.setItem(
STORAGE_KEYS.LOCAL_STORAGE_APP_STATE,
JSON.stringify(clearAppStateForLocalStorage(appState)),
JSON.stringify(_appState),
);
updateBrowserStateVersion(STORAGE_KEYS.VERSION_DATA_STATE);
} catch (error: any) {
Expand Down
Loading

0 comments on commit 72b7c93

Please sign in to comment.