Skip to content

Commit

Permalink
feat: Removed default value for isOverflowVisible in ModalDialog comp…
Browse files Browse the repository at this point in the history
…onent
  • Loading branch information
PKulkoRaccoonGang committed Nov 11, 2024
1 parent b4d560b commit 7cfbd7b
Show file tree
Hide file tree
Showing 3 changed files with 104 additions and 9 deletions.
10 changes: 7 additions & 3 deletions src/Modal/ModalDialog.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,13 @@ ModalDialog.propTypes = {
* Specifies the z-index of the modal
*/
zIndex: PropTypes.number,
/** Specifies whether overflow is visible in the modal */
isOverflowVisible: PropTypes.bool,
/**
* Specifies whether overflow content inside the modal should be visible.
* - `true` - content that exceeds the modal boundaries will remain visible outside the modal's main viewport,
* rather than being clipped or hidden.
* - `false` - any overflow content will be clipped to fit within the modal's dimensions.
*/
isOverflowVisible: PropTypes.bool.isRequired,
};

ModalDialog.defaultProps = {
Expand All @@ -137,7 +142,6 @@ ModalDialog.defaultProps = {
isFullscreenOnMobile: false,
isBlocking: false,
zIndex: undefined,
isOverflowVisible: true,
};

ModalDialog.Header = ModalDialogHeader;
Expand Down
101 changes: 95 additions & 6 deletions src/Modal/modal-dialog.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,13 @@ label for the dialog element.
const variants = ['default', 'warning', 'danger', 'success', 'dark'];
const [modalSize, setModalSize] = useState('md');
const [modalVariant, setModalVariant] = useState('default');

return (
<>
<div className="d-flex">
<Button variant="outline-primary" onClick={open}>Open standard modal dialog</Button>
<Button variant="outline-primary" onClick={open}>
Open standard modal dialog
</Button>
</div>
<ModalDialog
title="My dialog"
Expand All @@ -44,6 +47,7 @@ label for the dialog element.
variant={modalVariant}
hasCloseButton
isFullscreenOnMobile
isOverflowVisible
>
<ModalDialog.Header>
<ModalDialog.Title>
Expand Down Expand Up @@ -73,7 +77,11 @@ label for the dialog element.
</Form.RadioSet>
</Form.Group>
<p>
I'm baby palo santo ugh celiac fashion axe. La croix lo-fi venmo whatever. Beard man braid migas single-origin coffee forage ramps. Tumeric messenger bag bicycle rights wayfarers, try-hard cronut blue bottle health goth. Sriracha tumblr cardigan, cloud bread succulents tumeric copper mug marfa semiotics woke next level organic roof party +1 try-hard.
I'm baby palo santo ugh celiac fashion axe. La croix lo-fi venmo whatever.
Beard man braid migas single-origin coffee forage ramps. Tumeric messenger
bag bicycle rights wayfarers, try-hard cronut blue bottle health goth.
Sriracha tumblr cardigan, cloud bread succulents tumeric copper mug marfa
semiotics woke next level organic roof party +1 try-hard.
</p>
</ModalDialog.Body>

Expand All @@ -82,7 +90,7 @@ label for the dialog element.
<ModalDialog.CloseButton variant="tertiary">
Cancel
</ModalDialog.CloseButton>
<Button variant="primary">
<Button>
A button
</Button>
</ActionRow>
Expand All @@ -102,10 +110,13 @@ label for the dialog element.
const variants = ['default', 'warning', 'danger', 'success', 'dark'];
const [modalSize, setModalSize] = useState('md');
const [modalVariant, setModalVariant] = useState('dark');

return (
<>
<div className="d-flex">
<Button variant="outline-primary" onClick={open}>Open marketing modal dialog</Button>
<Button variant="outline-primary" onClick={open}>
Open marketing modal dialog
</Button>
</div>
<ModalDialog
title="My dialog"
Expand All @@ -114,6 +125,7 @@ label for the dialog element.
size={modalSize}
variant={modalVariant}
hasCloseButton
isOverflowVisible
>
<ModalDialog.Hero>
<ModalDialog.Hero.Background
Expand Down Expand Up @@ -144,7 +156,11 @@ label for the dialog element.
</Form.RadioSet>
</Form.Group>
<p>
I'm baby palo santo ugh celiac fashion axe. La croix lo-fi venmo whatever. Beard man braid migas single-origin coffee forage ramps. Tumeric messenger bag bicycle rights wayfarers, try-hard cronut blue bottle health goth. Sriracha tumblr cardigan, cloud bread succulents tumeric copper mug marfa semiotics woke next level organic roof party +1 try-hard.
I'm baby palo santo ugh celiac fashion axe. La croix lo-fi venmo whatever.
Beard man braid migas single-origin coffee forage ramps. Tumeric messenger
bag bicycle rights wayfarers, try-hard cronut blue bottle health goth.
Sriracha tumblr cardigan, cloud bread succulents tumeric copper mug marfa
semiotics woke next level organic roof party +1 try-hard.
</p>
</ModalDialog.Body>

Expand All @@ -153,7 +169,80 @@ label for the dialog element.
<ModalDialog.CloseButton variant="tertiary">
Cancel
</ModalDialog.CloseButton>
<Button variant="primary">
<Button>
A button
</Button>
</ActionRow>
</ModalDialog.Footer>
</ModalDialog>
</>
)
}
```

## Overflow visibility handling

The `isOverflowVisible` toggle controls whether content that extends beyond the modal's viewport boundaries is visible.
When enabled (`isOverflowVisible` is set to `true`), any overflow content, such as dropdowns or tooltips,
will be displayed outside the modal's main area instead of being clipped.

In this example, switching `isOverflowVisible` on and off affects the visibility of the dropdown options in
the autosuggest field, showing how overflow handling impacts content display within a modal.

```jsx live
() => {
const [isOpen, open, close] = useToggle(false);
const [isOn, setOn, setOff, toggle] = useToggle(false);

return (
<>
<div className="d-flex">
<Button variant="outline-primary" onClick={open}>
Open standard modal dialog
</Button>
</div>
<ModalDialog
title="My dialog"
isOpen={isOpen}
onClose={close}
hasCloseButton
isFullscreenOnMobile
isOverflowVisible={isOn}
>
<ModalDialog.Header>
<ModalDialog.Title>
I'm a dialog box
</ModalDialog.Title>
</ModalDialog.Header>
<ModalDialog.Body>
<Stack className="mb-3" direction="horizontal" gap={2}>
<Form.Switch checked={isOn} onChange={toggle}>
isOverflowVisible
</Form.Switch>
{isOn
? <Badge variant="success">{JSON.stringify(isOn)}</Badge>
: <Badge variant="light">{JSON.stringify(isOn)}</Badge>
}
</Stack>
<Form.Autosuggest
aria-label="form autosuggest"
helpMessage="Select language"
placeholder="Open autosuggest dropdown"
>
<Form.AutosuggestOption id="javascript-option-id">JavaScript</Form.AutosuggestOption>
<Form.AutosuggestOption id="python-option-id">Python</Form.AutosuggestOption>
<Form.AutosuggestOption id="ruby-option-id">Ruby</Form.AutosuggestOption>
<Form.AutosuggestOption id="c-option-id">C</Form.AutosuggestOption>
</Form.Autosuggest>
</ModalDialog.Body>
<ModalDialog.Footer>
<ActionRow>
<ModalDialog.CloseButton variant="tertiary">
Cancel
</ModalDialog.CloseButton>
<Button>
A button
</Button>
</ActionRow>
Expand Down
2 changes: 2 additions & 0 deletions src/Modal/tests/ModalDialog.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ describe('ModalDialog', () => {
size="md"
variant="default"
hasCloseButton
isOverflowVisible
>
<ModalDialog.Header>
<ModalDialog.Title>The title</ModalDialog.Title>
Expand Down Expand Up @@ -58,6 +59,7 @@ describe('ModalDialog with Hero', () => {
size="md"
variant="default"
hasCloseButton
isOverflowVisible
>
<ModalDialog.Hero>
<ModalDialog.Hero.Background backgroundSrc="imageurl" />
Expand Down

0 comments on commit 7cfbd7b

Please sign in to comment.