Virtual whiteboard for sketching hand-drawn like diagrams
fix(editor): show scroll-back-to-content button on mobile (#11680)
David Luzara1d9b16b0dc4
diff --git a/packages/excalidraw/components/LayerUI.tsx b/packages/excalidraw/components/LayerUI.tsxindex eba358c0ae..43ded1403c 100644--- a/packages/excalidraw/components/LayerUI.tsx+++ b/packages/excalidraw/components/LayerUI.tsx@@ -595,7 +595,6 @@ const LayerUI = ({renderWelcomeScreen={renderWelcomeScreen}defaultUIEnabled={defaultUIEnabled}scrollBackToContentUIEnabled={scrollBackToContentUIEnabled}- UIOptions={UIOptions}/>)}{editorInterface.formFactor !== "phone" && (diff --git a/packages/excalidraw/components/MobileMenu.tsx b/packages/excalidraw/components/MobileMenu.tsxindex 43f2833f12..8927f61361 100644--- a/packages/excalidraw/components/MobileMenu.tsx+++ b/packages/excalidraw/components/MobileMenu.tsx@@ -16,12 +16,7 @@ import { Island } from "./Island";import { PenModeButton } from "./PenModeButton";import type { ActionManager } from "../actions/manager";-import type {- AppClassProperties,- AppProps,- AppState,- UIAppState,-} from "../types";+import type { AppClassProperties, AppState, UIAppState } from "../types";import type { JSX } from "react";type MobileMenuProps = {@@ -45,7 +40,6 @@ type MobileMenuProps = {renderWelcomeScreen: boolean;defaultUIEnabled: boolean;scrollBackToContentUIEnabled: boolean;- UIOptions: AppProps["UIOptions"];app: AppClassProperties;};@@ -60,7 +54,6 @@ export const MobileMenu = ({renderWelcomeScreen,defaultUIEnabled,scrollBackToContentUIEnabled,- UIOptions,app,onPenModeToggle,}: MobileMenuProps) => {@@ -125,6 +118,27 @@ export const MobileMenu = ({return <MobileToolbar app={app} setAppState={setAppState} />;};+ const shouldRenderScrollBackToContent =+ scrollBackToContentUIEnabled && appState.scrolledOutside;+ const shouldRenderDefaultBottomBar =+ defaultUIEnabled && !appState.viewModeEnabled;+ const scrollBackToContentButton =+ shouldRenderScrollBackToContent &&+ !appState.openMenu &&+ !appState.openSidebar ? (+ <button+ type="button"+ className="scroll-back-to-content"+ onClick={() => {+ setAppState((appState) => ({+ ...getScrollToContentState(elements, appState),+ }));+ }}+ >+ {t("buttons.scrollBackToContent")}+ </button>+ ) : null;+return (<>{renderSidebars()}@@ -134,50 +148,33 @@ export const MobileMenu = ({{renderWelcomeScreen && <WelcomeScreenCenterTunnel.Out />}</div>- {!appState.viewModeEnabled &&- (defaultUIEnabled ||- (scrollBackToContentUIEnabled && appState.scrolledOutside)) && (- <div- className="App-bottom-bar"- style={{- marginBottom: SCROLLBAR_WIDTH + SCROLLBAR_MARGIN,- }}- data-viewport-ui="bottom"- >- {defaultUIEnabled && (- <MobileShapeActions- appState={appState}- elementsMap={app.scene.getNonDeletedElementsMap()}- renderAction={actionManager.renderAction}- app={app}- setAppState={setAppState}- />- )}-- <Island className="App-toolbar">- {defaultUIEnabled &&- !appState.viewModeEnabled &&- appState.openDialog?.name !== "elementLinkSelector" &&- renderToolbar()}- {scrollBackToContentUIEnabled &&- appState.scrolledOutside &&- !appState.openMenu &&- !appState.openSidebar && (- <button- type="button"- className="scroll-back-to-content"- onClick={() => {- setAppState((appState) => ({- ...getScrollToContentState(elements, appState),- }));- }}- >- {t("buttons.scrollBackToContent")}- </button>- )}- </Island>- </div>- )}+ {shouldRenderDefaultBottomBar && (+ <div+ className="App-bottom-bar"+ style={{+ marginBottom: SCROLLBAR_WIDTH + SCROLLBAR_MARGIN,+ }}+ data-viewport-ui="bottom"+ >+ <MobileShapeActions+ appState={appState}+ elementsMap={app.scene.getNonDeletedElementsMap()}+ renderAction={actionManager.renderAction}+ app={app}+ setAppState={setAppState}+ />++ <Island className="App-toolbar">+ {appState.openDialog?.name !== "elementLinkSelector" &&+ renderToolbar()}+ {scrollBackToContentButton}+ </Island>+ </div>+ )}++ {!shouldRenderDefaultBottomBar && scrollBackToContentButton && (+ <div className="floating-status-stack">{scrollBackToContentButton}</div>+ )}<FixedSideContainer side="top" className="App-top-bar">{renderAppTopBar()}diff --git a/packages/excalidraw/css/styles.scss b/packages/excalidraw/css/styles.scssindex c694d24c40..918834ef57 100644--- a/packages/excalidraw/css/styles.scss+++ b/packages/excalidraw/css/styles.scss@@ -583,10 +583,21 @@ body.excalidraw-cursor-resize * {aside {display: none;}++ .floating-status-stack {+ bottom: calc(30px + var(--sab, 0));+ z-index: var(--zIndex-ui-bottom);+ }+.scroll-back-to-content {bottom: calc(100px + var(--sab, 0));z-index: -1;}++ .floating-status-stack .scroll-back-to-content {+ bottom: auto;+ z-index: auto;+ }}.rtl-mirror {