mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-08-10 13:38:49 +08:00
fix: use overflow: clip instead of js to prevent scrolling with pgup/pgdown (#6338)
This commit is contained in:
@@ -49,7 +49,7 @@ export const mainContainerStyle = style({
|
|||||||
width: 0,
|
width: 0,
|
||||||
display: 'flex',
|
display: 'flex',
|
||||||
flex: 1,
|
flex: 1,
|
||||||
overflow: 'hidden',
|
overflow: 'clip',
|
||||||
maxWidth: '100%',
|
maxWidth: '100%',
|
||||||
transition: 'margin-left 0.2s ease',
|
transition: 'margin-left 0.2s ease',
|
||||||
selectors: {
|
selectors: {
|
||||||
|
|||||||
@@ -27,14 +27,13 @@ import {
|
|||||||
} from '@toeverything/infra';
|
} from '@toeverything/infra';
|
||||||
import clsx from 'clsx';
|
import clsx from 'clsx';
|
||||||
import { useSetAtom } from 'jotai';
|
import { useSetAtom } from 'jotai';
|
||||||
import type { KeyboardEventHandler, ReactElement } from 'react';
|
import type { ReactElement } from 'react';
|
||||||
import {
|
import {
|
||||||
memo,
|
memo,
|
||||||
useCallback,
|
useCallback,
|
||||||
useEffect,
|
useEffect,
|
||||||
useLayoutEffect,
|
useLayoutEffect,
|
||||||
useMemo,
|
useMemo,
|
||||||
useRef,
|
|
||||||
useState,
|
useState,
|
||||||
} from 'react';
|
} from 'react';
|
||||||
import { useParams } from 'react-router-dom';
|
import { useParams } from 'react-router-dom';
|
||||||
@@ -203,17 +202,6 @@ const DetailPageImpl = memo(function DetailPageImpl() {
|
|||||||
);
|
);
|
||||||
|
|
||||||
const isWindowsDesktop = environment.isDesktop && environment.isWindows;
|
const isWindowsDesktop = environment.isDesktop && environment.isWindows;
|
||||||
const scrollableRef = useRef<HTMLDivElement>(null);
|
|
||||||
const keydownHandler: KeyboardEventHandler = useCallback(e => {
|
|
||||||
// prevent pgup/pgdown from scrolling the page
|
|
||||||
if (e.key === 'PageUp' || e.key === 'PageDown') {
|
|
||||||
e.preventDefault();
|
|
||||||
scrollableRef.current?.scrollBy({
|
|
||||||
top: e.key === 'PageUp' ? -window.innerHeight : window.innerHeight,
|
|
||||||
behavior: 'smooth',
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
@@ -230,8 +218,6 @@ const DetailPageImpl = memo(function DetailPageImpl() {
|
|||||||
<TopTip pageId={currentPageId} workspace={currentWorkspace} />
|
<TopTip pageId={currentPageId} workspace={currentWorkspace} />
|
||||||
<Scrollable.Root>
|
<Scrollable.Root>
|
||||||
<Scrollable.Viewport
|
<Scrollable.Viewport
|
||||||
ref={scrollableRef}
|
|
||||||
onKeyDown={keydownHandler}
|
|
||||||
className={clsx(
|
className={clsx(
|
||||||
'affine-page-viewport',
|
'affine-page-viewport',
|
||||||
styles.affineDocViewport,
|
styles.affineDocViewport,
|
||||||
|
|||||||
Reference in New Issue
Block a user