Skip to content

Commit c010b85

Browse files
authored
feat: Add ref support to ModalBody component (#841)
* feat: Forward ref to ModalBody * chore: Bump version minor
1 parent e2e97b4 commit c010b85

File tree

4 files changed

+15
-6
lines changed

4 files changed

+15
-6
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
Reactist follows [semantic versioning](https://semver.org/) and doesn't introduce breaking changes (API-wise) in minor or patch releases. However, the appearance of a component might change in a minor or patch release so keep an eye on redesigns and make sure your app still looks and feels like you expect it.
44

5+
# v25.2.0
6+
7+
- [Feat] Add `ref` support to `ModalBody` component
8+
59
# v25.1.1
610

711
- [Fix] Restrict focus locking in the `Modal` component to its containing document/iframe.

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"email": "henning@doist.com",
77
"url": "http://doist.com"
88
},
9-
"version": "25.1.1",
9+
"version": "25.2.0",
1010
"license": "MIT",
1111
"homepage": "https://github.com/Doist/reactist#readme",
1212
"repository": {

src/modal/modal.tsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import { IconButtonProps, IconButton } from '../button'
1414

1515
import styles from './modal.module.css'
1616
import type { ObfuscatedClassName } from '../utils/common-types'
17+
import { forwardRef } from 'react'
1718

1819
type ModalWidth = 'xsmall' | 'small' | 'medium' | 'large' | 'xlarge' | 'full'
1920
type ModalHeightMode = 'expand' | 'fitContent'
@@ -426,19 +427,23 @@ export interface ModalBodyProps extends DivProps, ObfuscatedClassName {
426427
* Renders the body of a modal.
427428
*
428429
* Convenient to use alongside ModalHeader and/or ModalFooter as needed. It ensures, among other
429-
* things, that the contet of the modal body expands or contracts depending on the modal height
430+
* things, that the content of the modal body expands or contracts depending on the modal height
430431
* setting or the size of the content. The body content also automatically scrolls when it's too
431432
* large to fit the available space.
432433
*
433434
* @see Modal
434435
* @see ModalHeader
435436
* @see ModalFooter
436437
*/
437-
export function ModalBody({ exceptionallySetClassName, children, ...props }: ModalBodyProps) {
438+
export const ModalBody = forwardRef<HTMLDivElement, ModalBodyProps>(function ModalBody(
439+
{ exceptionallySetClassName, children, ...props },
440+
ref,
441+
) {
438442
const { height } = React.useContext(ModalContext)
439443
return (
440444
<Box
441445
{...props}
446+
ref={ref}
442447
className={exceptionallySetClassName}
443448
flexGrow={height === 'expand' ? 1 : 0}
444449
height={height === 'expand' ? 'full' : undefined}
@@ -449,7 +454,7 @@ export function ModalBody({ exceptionallySetClassName, children, ...props }: Mod
449454
</Box>
450455
</Box>
451456
)
452-
}
457+
})
453458

454459
//
455460
// ModalFooter

0 commit comments

Comments
 (0)