fix: menu in peek view content not scrollable issue (#7412)
when using [dialog.overlay](https://github.com/radix-ui/primitives/blob/main/packages/react/dialog/src/Dialog.tsx#L203-L211
), whole app is affected by [react-scroll library](8923c513d2/src/SideEffect.tsx (L131-L134)
):
In the current implementation, only the contents in the dialog content will be scrollable and cannot be configured in current API.
This PR introduces a simple div overlay to get rid of this issue.
fix BS-696
This commit is contained in:
@@ -100,6 +100,7 @@ export const modalOverlay = style({
|
|||||||
zIndex: cssVar('zIndexModal'),
|
zIndex: cssVar('zIndexModal'),
|
||||||
backgroundColor: cssVar('black30'),
|
backgroundColor: cssVar('black30'),
|
||||||
viewTransitionName: vtOverlayFade,
|
viewTransitionName: vtOverlayFade,
|
||||||
|
pointerEvents: 'auto',
|
||||||
});
|
});
|
||||||
|
|
||||||
export const modalContentWrapper = style({
|
export const modalContentWrapper = style({
|
||||||
|
|||||||
@@ -18,7 +18,11 @@ const contentOptions: Dialog.DialogContentProps = {
|
|||||||
['data-testid' as string]: 'peek-view-modal',
|
['data-testid' as string]: 'peek-view-modal',
|
||||||
onPointerDownOutside: e => {
|
onPointerDownOutside: e => {
|
||||||
const el = e.target as HTMLElement;
|
const el = e.target as HTMLElement;
|
||||||
if (el.closest('[data-peek-view-wrapper]')) {
|
if (
|
||||||
|
el.closest('[data-peek-view-wrapper]') ||
|
||||||
|
// workaround for slash menu click outside issue
|
||||||
|
el.closest('affine-slash-menu')
|
||||||
|
) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -83,6 +87,8 @@ export type PeekViewModalContainerProps = PropsWithChildren<{
|
|||||||
testId?: string;
|
testId?: string;
|
||||||
}>;
|
}>;
|
||||||
|
|
||||||
|
const PeekViewModalOverlay = 'div';
|
||||||
|
|
||||||
export const PeekViewModalContainer = forwardRef<
|
export const PeekViewModalContainer = forwardRef<
|
||||||
HTMLDivElement,
|
HTMLDivElement,
|
||||||
PeekViewModalContainerProps
|
PeekViewModalContainerProps
|
||||||
@@ -149,7 +155,7 @@ export const PeekViewModalContainer = forwardRef<
|
|||||||
<PeekViewContext.Provider value={emptyContext}>
|
<PeekViewContext.Provider value={emptyContext}>
|
||||||
<Dialog.Root modal open={vtOpen} onOpenChange={onOpenChange}>
|
<Dialog.Root modal open={vtOpen} onOpenChange={onOpenChange}>
|
||||||
<Dialog.Portal>
|
<Dialog.Portal>
|
||||||
<Dialog.Overlay
|
<PeekViewModalOverlay
|
||||||
className={styles.modalOverlay}
|
className={styles.modalOverlay}
|
||||||
onAnimationStart={onAnimationStart}
|
onAnimationStart={onAnimationStart}
|
||||||
onAnimationEnd={onAnimateEnd}
|
onAnimationEnd={onAnimateEnd}
|
||||||
|
|||||||
Reference in New Issue
Block a user