mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-08-03 02:20:19 +08:00
fix(core): add null checks for timeout refs and event listeners for React 19 compatibility (#9116)
## Description - Add null checks before clearTimeout calls in colorful-fallback.tsx, edgeless.dialog.tsx, and local.dialog.tsx - Fix event listener cleanup in unfolding.tsx - Update tsconfig.jsx to use react-jsx transform ## Testing - [x] Verified type safety improvements for React 19 compatibility - [x] Ensured proper cleanup of event listeners and timeouts - [x] Confirmed no unintended side effects from the changes Link to Devin run: https://app.devin.ai/sessions/2e790f3ea0d84402837ec6c3c6f83e4c
This commit is contained in:
@@ -1,6 +1,11 @@
|
||||
import { SafeArea } from '@affine/component';
|
||||
import clsx from 'clsx';
|
||||
import type { HtmlHTMLAttributes, ReactElement, ReactNode } from 'react';
|
||||
import type {
|
||||
HtmlHTMLAttributes,
|
||||
ReactElement,
|
||||
ReactNode,
|
||||
SVGAttributes,
|
||||
} from 'react';
|
||||
import { forwardRef } from 'react';
|
||||
|
||||
import { NavigationBackButton } from '../navigation-back';
|
||||
@@ -12,7 +17,7 @@ export interface PageHeaderProps
|
||||
* whether to show back button
|
||||
*/
|
||||
back?: boolean;
|
||||
backIcon?: ReactElement;
|
||||
backIcon?: ReactElement<SVGAttributes<SVGElement>>;
|
||||
/**
|
||||
* Override back button action
|
||||
*/
|
||||
|
||||
@@ -139,7 +139,7 @@ const close = (
|
||||
};
|
||||
|
||||
const SwipeDialogContext = createContext<{
|
||||
stack: Array<RefObject<HTMLElement>>;
|
||||
stack: Array<RefObject<HTMLElement | null>>;
|
||||
}>({
|
||||
stack: [],
|
||||
});
|
||||
@@ -155,7 +155,7 @@ export const SwipeDialog = ({
|
||||
const { onOpen: globalOnOpen } = useContext(ModalConfigContext);
|
||||
const swiperTriggerRef = useRef<HTMLDivElement>(null);
|
||||
const overlayRef = useRef<HTMLDivElement>(null);
|
||||
const dialogRef = useRef<HTMLDivElement>(null);
|
||||
const dialogRef = useRef<HTMLDivElement | null>(null);
|
||||
|
||||
const { stack } = useContext(SwipeDialogContext);
|
||||
const prev = stack[stack.length - 1]?.current;
|
||||
@@ -187,9 +187,11 @@ export const SwipeDialog = ({
|
||||
onSwipeStart: () => {},
|
||||
onSwipe({ deltaX }) {
|
||||
const prevOrAppRoot = prev ?? document.querySelector('#app');
|
||||
if (!overlay || !dialog) return;
|
||||
tick(overlay, dialog, prevOrAppRoot, deltaX, overlay.clientWidth);
|
||||
},
|
||||
onSwipeEnd: ({ deltaX }) => {
|
||||
if (!overlay || !dialog) return;
|
||||
const shouldClose = deltaX > overlay.clientWidth * 0.2;
|
||||
if (shouldClose) {
|
||||
close(overlay, dialog, prev, deltaX, handleClose);
|
||||
|
||||
Reference in New Issue
Block a user