Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: missing Modal props and Overlay styles #1033

Merged
merged 1 commit into from
Mar 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion src/component-library/Modal/Modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,17 @@ type ModalProps = Props & InheritAttrs;

const Modal = forwardRef<HTMLDivElement, ModalProps>(
(
{ children, isDismissable = true, align = 'center', hasMaxHeight, isKeyboardDismissDisabled, container, ...props },
{
children,
isDismissable = true,
align = 'center',
hasMaxHeight,
isKeyboardDismissDisabled,
shouldCloseOnBlur,
shouldCloseOnInteractOutside,
container,
...props
},
ref
): JSX.Element | null => {
const domRef = useDOMRef(ref);
Expand All @@ -31,6 +41,8 @@ const Modal = forwardRef<HTMLDivElement, ModalProps>(
isDismissable={isDismissable}
isOpen={isOpen}
isKeyboardDismissDisabled={isKeyboardDismissDisabled}
shouldCloseOnBlur={shouldCloseOnBlur}
shouldCloseOnInteractOutside={shouldCloseOnInteractOutside}
onClose={onClose}
>
<Dialog hasMaxHeight={hasMaxHeight} align={align} {...props}>
Expand Down
20 changes: 18 additions & 2 deletions src/component-library/Modal/ModalWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,29 @@ type ModalWrapperProps = Props & InheritAttrs;

const ModalWrapper = forwardRef<HTMLDivElement, ModalWrapperProps>(
(
{ children, isDismissable = true, align = 'center', onClose, isKeyboardDismissDisabled, isOpen, ...props },
{
children,
isDismissable = true,
align = 'center',
onClose,
isKeyboardDismissDisabled,
isOpen,
shouldCloseOnInteractOutside,
shouldCloseOnBlur,
...props
},
ref
): JSX.Element | null => {
// Handle interacting outside the dialog and pressing
// the Escape key to close the modal.
const { modalProps, underlayProps } = useModalOverlay(
{ isDismissable, isKeyboardDismissDisabled, ...props },
{
isDismissable,
isKeyboardDismissDisabled,
shouldCloseOnInteractOutside,
shouldCloseOnBlur,
...props
} as AriaOverlayProps,
// These are the only props needed
{ isOpen: !!isOpen, close: onClose } as OverlayTriggerState,
ref as RefObject<HTMLElement>
Expand Down
8 changes: 8 additions & 0 deletions src/component-library/Overlay/Overlay.style.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import styled from 'styled-components';

const StyledOverlayWrapper = styled.div`
isolation: isolate;
background: transparent;
`;

export { StyledOverlayWrapper };
5 changes: 3 additions & 2 deletions src/component-library/Overlay/Overlay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Overlay as AriaOverlay } from '@react-aria/overlays';
import { ReactNode, useCallback, useState } from 'react';

import { OpenTransition } from './OpenTransition';
import { StyledOverlayWrapper } from './Overlay.style';

type OverlayProps = {
children: ReactNode;
Expand Down Expand Up @@ -53,7 +54,7 @@ const Overlay = ({

return (
<AriaOverlay portalContainer={container}>
<div>
<StyledOverlayWrapper>
<OpenTransition
in={isOpen}
appear
Expand All @@ -66,7 +67,7 @@ const Overlay = ({
>
{children}
</OpenTransition>
</div>
</StyledOverlayWrapper>
</AriaOverlay>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ const SlippageManager = forwardRef<HTMLDivElement, SlippageManagerProps>(
const handleSelectionChange: ListProps['onSelectionChange'] = (key) => {
const [selectedKey] = [...key];

if (!selectedKey) return;
if (!selectedKey) {
return setOpen(false);
}

onChange?.(Number(selectedKey));
setOpen(false);
Expand Down