There can be more than Notion and Miro. AFFiNE(pronounced [ə‘fain]) is a next-gen knowledge base that brings planning, sorting and creating all together. Privacy first, open-source, customizable and ready to use.
TypeScript appcrdteditorelectronknowledge-basemarkdownmironotesnotionnotion-alternativerustrust-langrust-languagetabletableviewwhiteboardwikiworkspace
fix(mobile): scroll optimization (#8362)
CatsJuice9eae3de1ae7f
diff --git a/packages/frontend/component/src/hooks/use-theme-color-meta.ts b/packages/frontend/component/src/hooks/use-theme-color-meta.tsindex fa1a6aaf2b..e02e6acb21 100644--- a/packages/frontend/component/src/hooks/use-theme-color-meta.ts+++ b/packages/frontend/component/src/hooks/use-theme-color-meta.ts@@ -25,9 +25,13 @@ export const useThemeColorMeta = (color: string) => {const meta = getMeta();const old = meta.content;meta.content = color;+ // also modify document background (for over scroll bounce effect)+ const oldBg = document.documentElement.style.backgroundColor;+ document.documentElement.style.backgroundColor = color;return () => {meta.content = old;+ document.documentElement.style.backgroundColor = oldBg;};}, [color]);};diff --git a/packages/frontend/component/src/ui/button/button.tsx b/packages/frontend/component/src/ui/button/button.tsxindex acc066adf3..b02cf212e5 100644--- a/packages/frontend/component/src/ui/button/button.tsx+++ b/packages/frontend/component/src/ui/button/button.tsx@@ -161,7 +161,9 @@ export const Button = forwardRef<HTMLButtonElement, ButtonProps>(data-disabled={disabled || undefined}data-size={size}data-variant={variant}- data-no-hover={withoutHover || undefined}+ data-no-hover={+ withoutHover || BUILD_CONFIG.isMobileEdition || undefined+ }data-mobile={BUILD_CONFIG.isMobileEdition}onClick={handleClick}>diff --git a/packages/frontend/core/src/components/hooks/use-navigate-helper.ts b/packages/frontend/core/src/components/hooks/use-navigate-helper.tsindex 68871f9374..483735c196 100644--- a/packages/frontend/core/src/components/hooks/use-navigate-helper.ts+++ b/packages/frontend/core/src/components/hooks/use-navigate-helper.ts@@ -96,8 +96,8 @@ export function useNavigateHelper() {);const openPage = useCallback(- (workspaceId: string, pageId: string) => {- return jumpToPage(workspaceId, pageId);+ (workspaceId: string, pageId: string, logic?: RouteLogic) => {+ return jumpToPage(workspaceId, pageId, logic);},[jumpToPage]);diff --git a/packages/frontend/core/src/desktop/pages/index.tsx b/packages/frontend/core/src/desktop/pages/index.tsxindex 73723583c0..6b24f8f5dd 100644--- a/packages/frontend/core/src/desktop/pages/index.tsx+++ b/packages/frontend/core/src/desktop/pages/index.tsx@@ -15,7 +15,10 @@ import {import { type LoaderFunction, useSearchParams } from 'react-router-dom';import { AppFallback } from '../../components/affine/app-container';-import { useNavigateHelper } from '../../components/hooks/use-navigate-helper';+import {+ RouteLogic,+ useNavigateHelper,+} from '../../components/hooks/use-navigate-helper';import { WorkspaceNavigator } from '../../components/workspace-selector';import { AuthService } from '../../modules/cloud';import {@@ -102,7 +105,7 @@ export const Component = ({const lastId = localStorage.getItem('last_workspace_id');const openWorkspace = list.find(w => w.id === lastId) ?? list[0];- openPage(openWorkspace.id, defaultIndexRoute);+ openPage(openWorkspace.id, defaultIndexRoute, RouteLogic.REPLACE);}}, [createCloudWorkspace,diff --git a/packages/frontend/core/src/mobile/components/page-header/index.tsx b/packages/frontend/core/src/mobile/components/page-header/index.tsxindex 9a7383b3dd..661610b45e 100644--- a/packages/frontend/core/src/mobile/components/page-header/index.tsx+++ b/packages/frontend/core/src/mobile/components/page-header/index.tsx@@ -65,41 +65,50 @@ export const PageHeader = forwardRef<HTMLDivElement, PageHeaderProps>(}, [backAction]);return (- <SafeArea- top- ref={ref}- className={clsx(styles.root, className)}- data-testid="mobile-page-header"- {...attrs}- >- <header className={styles.inner}>- <section- className={clsx(styles.prefix, prefixClassName)}- style={prefixStyle}- >- {back ? (- <IconButton- size={24}- style={{ padding: 10 }}- onClick={handleRouteBack}- icon={<ArrowLeftSmallIcon />}- />- ) : null}- {prefix}- </section>+ <>+ <SafeArea+ top+ ref={ref}+ className={clsx(styles.root, className)}+ data-testid="mobile-page-header"+ {...attrs}+ >+ <header className={styles.inner}>+ <section+ className={clsx(styles.prefix, prefixClassName)}+ style={prefixStyle}+ >+ {back ? (+ <IconButton+ size={24}+ style={{ padding: 10 }}+ onClick={handleRouteBack}+ icon={<ArrowLeftSmallIcon />}+ />+ ) : null}+ {prefix}+ </section>- <section className={clsx(styles.content, { center: centerContent })}>- {children}- </section>+ <section+ className={clsx(styles.content, { center: centerContent })}+ >+ {children}+ </section>- <section- className={clsx(styles.suffix, suffixClassName)}- style={suffixStyle}- >- {suffix}- </section>- </header>- </SafeArea>+ <section+ className={clsx(styles.suffix, suffixClassName)}+ style={suffixStyle}+ >+ {suffix}+ </section>+ </header>+ </SafeArea>++ {/* Spacer */}+ <SafeArea top>+ <div className={styles.headerSpacer} />+ </SafeArea>+ </>);});diff --git a/packages/frontend/core/src/mobile/components/page-header/styles.css.ts b/packages/frontend/core/src/mobile/components/page-header/styles.css.tsindex 6a2f9af065..d3f790591b 100644--- a/packages/frontend/core/src/mobile/components/page-header/styles.css.ts+++ b/packages/frontend/core/src/mobile/components/page-header/styles.css.ts@@ -3,13 +3,16 @@ import { style } from '@vanilla-extract/css';export const root = style({width: '100%',- position: 'sticky',+ position: 'fixed',top: 0,zIndex: 1,backgroundColor: cssVarV2('layer/background/secondary'),});+export const headerSpacer = style({+ height: 44,+});export const inner = style({- minHeight: 44,+ height: 44,padding: '0 6px',display: 'flex',alignItems: 'center',diff --git a/packages/frontend/core/src/mobile/components/workspace-selector/menu.css.ts b/packages/frontend/core/src/mobile/components/workspace-selector/menu.css.tsindex b965e4a5f0..c49ae71218 100644--- a/packages/frontend/core/src/mobile/components/workspace-selector/menu.css.ts+++ b/packages/frontend/core/src/mobile/components/workspace-selector/menu.css.ts@@ -3,7 +3,8 @@ import { cssVarV2 } from '@toeverything/theme/v2';import { style } from '@vanilla-extract/css';export const root = style({- maxHeight: 'calc(100dvh - 100px)',+ maxHeight:+ 'calc(100dvh - 100px - env(safe-area-inset-bottom) - env(safe-area-inset-top))',display: 'flex',flexDirection: 'column',});diff --git a/packages/frontend/core/src/mobile/components/workspace-selector/menu.tsx b/packages/frontend/core/src/mobile/components/workspace-selector/menu.tsxindex e68732968f..fd57b7e59a 100644--- a/packages/frontend/core/src/mobile/components/workspace-selector/menu.tsx+++ b/packages/frontend/core/src/mobile/components/workspace-selector/menu.tsx@@ -116,7 +116,9 @@ export const SelectorMenu = ({ onClose }: { onClose?: () => void }) => {title="Cloud Sync"list={cloudWorkspaces}/>- <div className={styles.divider} />+ {cloudWorkspaces.length && localWorkspaces.length ? (+ <div className={styles.divider} />+ ) : null}<WorkspaceListonClose={onClose}title="Local Storage"diff --git a/packages/frontend/core/src/mobile/pages/workspace/detail/mobile-detail-page.css.ts b/packages/frontend/core/src/mobile/pages/workspace/detail/mobile-detail-page.css.tsindex 8a7558bf17..9cf9b651ac 100644--- a/packages/frontend/core/src/mobile/pages/workspace/detail/mobile-detail-page.css.ts+++ b/packages/frontend/core/src/mobile/pages/workspace/detail/mobile-detail-page.css.ts@@ -11,7 +11,7 @@ export const root = style({export const header = style({background: cssVarV2('layer/background/primary'),- position: 'sticky',+ position: 'fixed',top: 0,zIndex: 1,});diff --git a/packages/frontend/core/src/mobile/styles/mobile.css.ts b/packages/frontend/core/src/mobile/styles/mobile.css.tsindex 436be23d78..3431043154 100644--- a/packages/frontend/core/src/mobile/styles/mobile.css.ts+++ b/packages/frontend/core/src/mobile/styles/mobile.css.ts@@ -14,11 +14,13 @@ globalStyle(':root', {globalStyle('body', {height: 'auto',minHeight: '100dvh',+ overflowY: 'unset',});globalStyle('body:has(#app-tabs)', {paddingBottom: globalVars.appTabHeight,});globalStyle('html', {+ height: '100dvh',overflowY: 'auto',background: cssVarV2('layer/background/secondary'),});