mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-07-10 14:52:49 +02:00
Remove React.lazy on overlay and tooltip
This commit is contained in:
@@ -1,11 +1,10 @@
|
|||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
|
import { FocusTrap } from 'focus-trap-react';
|
||||||
import * as m from 'motion/react-m';
|
import * as m from 'motion/react-m';
|
||||||
import type { ReactNode } from 'react';
|
import type { ReactNode } from 'react';
|
||||||
import React, { Suspense , lazy, useRef } from 'react';
|
import React, { useRef } from 'react';
|
||||||
import { Portal } from './Portal';
|
import { Portal } from './Portal';
|
||||||
|
|
||||||
const FocusTrap = lazy(() => import('focus-trap-react'));
|
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
children: ReactNode;
|
children: ReactNode;
|
||||||
portalName: string;
|
portalName: string;
|
||||||
@@ -51,7 +50,6 @@ export function Overlay({
|
|||||||
return (
|
return (
|
||||||
<Portal name={portalName}>
|
<Portal name={portalName}>
|
||||||
{open && (
|
{open && (
|
||||||
<Suspense>
|
|
||||||
<FocusTrap
|
<FocusTrap
|
||||||
focusTrapOptions={{
|
focusTrapOptions={{
|
||||||
allowOutsideClick: true, // So we can still click toasts and things
|
allowOutsideClick: true, // So we can still click toasts and things
|
||||||
@@ -96,7 +94,6 @@ export function Overlay({
|
|||||||
{children}
|
{children}
|
||||||
</m.div>
|
</m.div>
|
||||||
</FocusTrap>
|
</FocusTrap>
|
||||||
</Suspense>
|
|
||||||
)}
|
)}
|
||||||
</Portal>
|
</Portal>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,17 +1,8 @@
|
|||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
import type {
|
import type { CSSProperties, KeyboardEvent, ReactNode } from 'react';
|
||||||
CSSProperties,
|
import React, { useRef, useState } from 'react';
|
||||||
KeyboardEvent,
|
|
||||||
ReactNode} from 'react';
|
|
||||||
import React, {
|
|
||||||
lazy,
|
|
||||||
Suspense,
|
|
||||||
useRef,
|
|
||||||
useState,
|
|
||||||
} from 'react';
|
|
||||||
import { generateId } from '../../lib/generateId';
|
import { generateId } from '../../lib/generateId';
|
||||||
|
import { Portal } from '../Portal';
|
||||||
const Portal = lazy(() => import('../Portal').then((m) => ({ default: m.Portal })));
|
|
||||||
|
|
||||||
export interface TooltipProps {
|
export interface TooltipProps {
|
||||||
children: ReactNode;
|
children: ReactNode;
|
||||||
@@ -75,7 +66,7 @@ export function Tooltip({ children, content, tabIndex, size = 'md' }: TooltipPro
|
|||||||
const id = useRef(`tooltip-${generateId()}`);
|
const id = useRef(`tooltip-${generateId()}`);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Suspense>
|
<>
|
||||||
<Portal name="tooltip">
|
<Portal name="tooltip">
|
||||||
<div
|
<div
|
||||||
ref={tooltipRef}
|
ref={tooltipRef}
|
||||||
@@ -114,7 +105,7 @@ export function Tooltip({ children, content, tabIndex, size = 'md' }: TooltipPro
|
|||||||
>
|
>
|
||||||
{children}
|
{children}
|
||||||
</span>
|
</span>
|
||||||
</Suspense>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user