fix: allow to toggle between modes when view only mode to make UI consistent (#3009)

This commit is contained in:
Aakansha Doshi 2021-02-12 14:10:40 +05:30 committed by GitHub
parent ecbd5ba55d
commit b5fc8757a4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 6 deletions

View File

@ -8,6 +8,7 @@ import {
} from "./types"; } from "./types";
import { ExcalidrawElement } from "../element/types"; import { ExcalidrawElement } from "../element/types";
import { AppState, ExcalidrawProps } from "../types"; import { AppState, ExcalidrawProps } from "../types";
import { MODES } from "../constants";
// This is the <App> component, but for now we don't care about anything but its // This is the <App> component, but for now we don't care about anything but its
// `canvas` state. // `canvas` state.
@ -68,7 +69,7 @@ export class ActionManager implements ActionsManagerInterface {
} }
const { viewModeEnabled } = this.getAppState(); const { viewModeEnabled } = this.getAppState();
if (viewModeEnabled) { if (viewModeEnabled) {
if (data[0].name !== "viewMode") { if (!Object.values(MODES).includes(data[0].name)) {
return false; return false;
} }
} }

View File

@ -3701,15 +3701,16 @@ class App extends React.Component<ExcalidrawProps, AppState> {
options.push(actionCopyAsSvg); options.push(actionCopyAsSvg);
} }
if (!element) { if (!element) {
const viewModeOptions: ContextMenuOption[] = [ const viewModeOptions = [
...options, ...options,
typeof this.props.gridModeEnabled === "undefined" &&
actionToggleGridMode,
typeof this.props.zenModeEnabled === "undefined" && actionToggleZenMode,
typeof this.props.viewModeEnabled === "undefined" &&
actionToggleViewMode,
actionToggleStats, actionToggleStats,
]; ];
if (typeof this.props.viewModeEnabled === "undefined") {
viewModeOptions.push(actionToggleViewMode);
}
ContextMenu.push({ ContextMenu.push({
options: viewModeOptions, options: viewModeOptions,
top: clientY, top: clientY,

View File

@ -99,3 +99,9 @@ export const ZOOM_STEP = 0.1;
export const IDLE_THRESHOLD = 60_000; export const IDLE_THRESHOLD = 60_000;
// Report a user active each ACTIVE_THRESHOLD milliseconds // Report a user active each ACTIVE_THRESHOLD milliseconds
export const ACTIVE_THRESHOLD = 3_000; export const ACTIVE_THRESHOLD = 3_000;
export const MODES = {
VIEW: "viewMode",
ZEN: "zenMode",
GRID: "gridMode",
};