Skip to content

Commit bbe2460

Browse files
committed
refactor: remove disableOverflow prop from Modal instances
1 parent 6aeb5e4 commit bbe2460

9 files changed

Lines changed: 31 additions & 42 deletions

File tree

src/components/AssetDetailsModal/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Asset } from '@polymeshassociation/polymesh-sdk/types';
22
import { useAssetDetails } from '~/hooks/polymesh/useAssetDetails';
3-
import Modal from '../Modal';
43
import { AssetDetailsCard } from '../AssetDetailsCard';
4+
import Modal from '../Modal';
55

66
interface IAssetDetailsModalProps {
77
asset: string | Asset;
@@ -14,7 +14,7 @@ export const AssetDetailsModal: React.FC<IAssetDetailsModalProps> = ({
1414
const { assetDetails, assetDetailsLoading } = useAssetDetails(asset);
1515

1616
return (
17-
<Modal handleClose={toggleModal} customWidth="780px" disableOverflow>
17+
<Modal handleClose={toggleModal} customWidth="780px">
1818
<AssetDetailsCard
1919
assetDetailsLoading={assetDetailsLoading}
2020
assetDetails={assetDetails}

src/components/CookieDeclarationModal/index.tsx

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import { useEffect, useRef, useState } from 'react';
22
import { useTheme } from 'styled-components';
33
import Modal from '~/components/Modal';
44
import { useWindowWidth } from '~/hooks/utility';
5-
import { setCookiebotThemeProperties } from '~/utils/cookiebotTheme';
65
import { isCookiebotEnabled } from '~/utils/cookiebot';
6+
import { setCookiebotThemeProperties } from '~/utils/cookiebotTheme';
77
import { Button, Heading } from '../UiKit';
88
import { StyledButtonsWrapper, StyledModalContent } from './styles';
99

@@ -171,12 +171,7 @@ const CookieDeclarationModal: React.FC<ICookieDeclarationModalProps> = ({
171171
if (!isOpen || !isDeclarationReady) return null;
172172

173173
return (
174-
<Modal
175-
handleClose={onClose}
176-
customWidth="fit-content"
177-
disableOverflow
178-
flexLayout
179-
>
174+
<Modal handleClose={onClose} customWidth="fit-content" flexLayout>
180175
<Heading type="h2" marginBottom={12}>
181176
Cookie Declaration
182177
</Heading>

src/components/Modal/index.tsx

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { useEffect } from 'react';
22
import { createPortal } from 'react-dom';
33
import { useWindowWidth } from '~/hooks/utility';
44
import Icon from '../Icon';
5-
import { StyledBackdrop, StyledModal, StyledCloseButton } from './styles';
5+
import { StyledBackdrop, StyledCloseButton, StyledModal } from './styles';
66

77
interface KeyboardEvent {
88
key: string;
@@ -11,7 +11,6 @@ interface KeyboardEvent {
1111
interface IModalProps {
1212
handleClose: () => void | React.ReactEventHandler | React.ChangeEventHandler;
1313
children: React.ReactNode;
14-
disableOverflow?: boolean;
1514
customWidth?: string;
1615
flexLayout?: boolean;
1716
}
@@ -21,7 +20,6 @@ const modalRoot = document.getElementById('modal-root') as Element;
2120
const Modal: React.FC<IModalProps> = ({
2221
handleClose,
2322
children,
24-
disableOverflow,
2523
customWidth,
2624
flexLayout,
2725
}) => {
@@ -58,11 +56,7 @@ const Modal: React.FC<IModalProps> = ({
5856

5957
return createPortal(
6058
<StyledBackdrop onMouseDown={handleBackdropClick}>
61-
<StyledModal
62-
$disableOverflow={disableOverflow}
63-
$customWidth={customWidth}
64-
$flexLayout={flexLayout}
65-
>
59+
<StyledModal $customWidth={customWidth} $flexLayout={flexLayout}>
6660
{isMobile && (
6761
<StyledCloseButton onClick={handleClose}>
6862
<Icon name="CloseIcon" size="24px" />

src/components/Modal/styles.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ export const StyledBackdrop = styled.div`
2828
`;
2929

3030
export const StyledModal = styled.div<{
31-
$disableOverflow?: boolean;
3231
$customWidth?: string;
3332
$flexLayout?: boolean;
3433
}>`
@@ -45,12 +44,13 @@ export const StyledModal = styled.div<{
4544
$customWidth ? `${$customWidth}` : '400px'};
4645
max-width: ${({ $customWidth }) =>
4746
$customWidth ? `${$customWidth}` : '504px'};
47+
min-height: 200px;
4848
max-height: 80vh;
4949
border-radius: 8px;
5050
}
5151
background-color: ${({ theme }) => theme.colors.modalBackground};
5252
box-shadow: ${({ theme }) => `0px 20px 40px ${theme.colors.shadow}`};
53-
${({ $disableOverflow }) => ($disableOverflow ? '' : `overflow-y: auto;`)}
53+
overflow-y: auto;
5454
5555
animation: modal-animation 250ms ease-out;
5656
@keyframes modal-animation {

src/components/UserAuth/components/PopupWelcome/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export const PopupWelcome = () => {
2828
return null;
2929
}
3030
return (
31-
<Modal handleClose={() => {}} disableOverflow customWidth="fit-content">
31+
<Modal handleClose={() => {}} customWidth="fit-content">
3232
<StyledWelcomeWrapper>
3333
<StyledWelcomePopup>
3434
<h3>Welcome to Polymesh!</h3>

src/layouts/Authorizations/components/AddNewAuth/index.tsx

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -156,20 +156,21 @@ export const AddNewAuth: React.FC<IAddNewAuthProps> = ({ toggleModal }) => {
156156
<Text bold marginBottom={3}>
157157
Authorization Type
158158
</Text>
159-
<StyledTypeSelectWrapper ref={typeRef}>
160-
<StyledTypeSelect
161-
onClick={handleTypeDropdownToggle}
162-
$expanded={typeDropdownExpanded}
163-
$isSelected={!!selectedAuthType}
164-
>
165-
<span>
166-
{selectedAuthType
167-
? splitCamelCase(selectedAuthType)
168-
: 'Select Authorization Type'}
169-
</span>
170-
171-
<Icon name="ExpandIcon" size="18px" />
172-
</StyledTypeSelect>
159+
<div ref={typeRef}>
160+
<StyledTypeSelectWrapper>
161+
<StyledTypeSelect
162+
onClick={handleTypeDropdownToggle}
163+
$expanded={typeDropdownExpanded}
164+
$isSelected={!!selectedAuthType}
165+
>
166+
<span>
167+
{selectedAuthType
168+
? splitCamelCase(selectedAuthType)
169+
: 'Select Authorization Type'}
170+
</span>
171+
<Icon name="ExpandIcon" size="18px" />
172+
</StyledTypeSelect>
173+
</StyledTypeSelectWrapper>
173174
{typeDropdownExpanded && (
174175
<StyledExpandedTypeSelect>
175176
{Object.values(AuthorizationType)
@@ -195,7 +196,7 @@ export const AddNewAuth: React.FC<IAddNewAuthProps> = ({ toggleModal }) => {
195196
))}
196197
</StyledExpandedTypeSelect>
197198
)}
198-
</StyledTypeSelectWrapper>
199+
</div>
199200
{selectedAuthType === 'RotatePrimaryKey' && (
200201
<StyledWarningMessage>
201202
Caution: This will remove the current primary key from your identity

src/layouts/Authorizations/components/AddNewAuth/styles.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,16 @@ export const StyledTypeSelect = styled.div<{
3232
`;
3333

3434
export const StyledExpandedTypeSelect = styled.div`
35-
position: absolute;
36-
top: 110%;
37-
left: 0;
35+
display: flex;
36+
flex-direction: column;
3837
width: 100%;
38+
margin-top: 4px;
3939
padding: 8px;
4040
max-height: 200px;
4141
background-color: ${({ theme }) => theme.colors.landingBackground};
4242
border: 1px solid #8f8f8f;
4343
border-radius: 8px;
44-
overflow-y: scroll;
45-
z-index: 1;
44+
overflow-y: auto;
4645
box-shadow: 0px 20px 40px ${({ theme }) => theme.colors.shadow};
4746
`;
4847

src/layouts/Settings/components/DefaultAddress/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ export const DefaultAddress = () => {
7979
)}
8080
</StyledValue>
8181
{addressSelectExpanded && (
82-
<Modal handleClose={toggleModal} disableOverflow>
82+
<Modal handleClose={toggleModal}>
8383
<Heading type="h4" marginBottom={48}>
8484
Default Wallet Address
8585
</Heading>

src/layouts/Transfers/components/TransfersHeader/components/CreateVenue/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ export const CreateVenue: React.FC<ICreateVenueProps> = ({ toggleModal }) => {
5555
}
5656
};
5757
return (
58-
<Modal handleClose={toggleModal} disableOverflow>
58+
<Modal handleClose={toggleModal}>
5959
<Heading type="h4" marginBottom={32}>
6060
Create New Venue
6161
</Heading>

0 commit comments

Comments
 (0)