mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-13 21:05:19 +00:00
fix(mobile): scroll optimization (#8362)
close AF-1421, AF-1418, AF-1423, AF-1358
This commit is contained in:
@@ -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]
|
||||
);
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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>
|
||||
</>
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
@@ -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',
|
||||
|
||||
@@ -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',
|
||||
});
|
||||
|
||||
@@ -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}
|
||||
<WorkspaceList
|
||||
onClose={onClose}
|
||||
title="Local Storage"
|
||||
|
||||
@@ -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,
|
||||
});
|
||||
|
||||
@@ -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'),
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user