Skip to content

Commit 4f4c74c

Browse files
committed
Update vendored Modal file
1 parent 4ee63e1 commit 4f4c74c

File tree

1 file changed

+26
-24
lines changed

1 file changed

+26
-24
lines changed

src/private/Modal.js

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// vendored from React-Bootstrap to allow us to set z-index of Modal backdrop
2-
// https://github.com/react-bootstrap/react-bootstrap/blob/93a8a0ef29409293dd69fad5873ad791634b3ed1/src/Modal.tsx
2+
// https://github.com/react-bootstrap/react-bootstrap/blob/be23c304fa40ddb209919b0faac1e5dd8cef53ad/src/Modal.tsx
33
import React, {useCallback, useMemo, useRef, useState} from 'react';
44

55
import classNames from 'classnames';
@@ -52,6 +52,7 @@ const Modal = React.forwardRef(
5252
contentClassName,
5353
children,
5454
dialogAs: Dialog,
55+
'data-bs-theme': dataBsTheme,
5556
'aria-labelledby': ariaLabelledby,
5657
'aria-describedby': ariaDescribedby,
5758
'aria-label': ariaLabel,
@@ -139,7 +140,7 @@ const Modal = React.forwardRef(
139140
});
140141

141142
// We prevent the modal from closing during a drag by detecting where the
142-
// the click originates from. If it starts in the modal and then ends outside
143+
// click originates from. If it starts in the modal and then ends outside
143144
// don't close.
144145
const handleDialogMouseDown = () => {
145146
waitingForMouseUpRef.current = true;
@@ -185,13 +186,16 @@ const Modal = React.forwardRef(
185186
};
186187

187188
const handleEscapeKeyDown = e => {
188-
if (!keyboard && backdrop === 'static') {
189-
// Call preventDefault to stop modal from closing in restart ui,
190-
// then play our animation.
189+
if (keyboard) {
190+
onEscapeKeyDown?.(e);
191+
} else {
192+
// Call preventDefault to stop modal from closing in @restart/ui.
191193
e.preventDefault();
192-
handleStaticModalAnimation();
193-
} else if (keyboard && onEscapeKeyDown) {
194-
onEscapeKeyDown(e);
194+
195+
if (backdrop === 'static') {
196+
// Play static modal animation.
197+
handleStaticModalAnimation();
198+
}
195199
}
196200
};
197201

@@ -224,19 +228,17 @@ const Modal = React.forwardRef(
224228
};
225229

226230
const renderBackdrop = useCallback(
227-
backdropProps => {
228-
return (
229-
<div
230-
{...backdropProps}
231-
className={classNames(
232-
`${bsPrefix}-backdrop`,
233-
backdropClassName,
234-
!animation && 'show'
235-
)}
236-
style={{zIndex}}
237-
/>
238-
);
239-
},
231+
backdropProps => (
232+
<div
233+
{...backdropProps}
234+
className={classNames(
235+
`${bsPrefix}-backdrop`,
236+
backdropClassName,
237+
!animation && 'show'
238+
)}
239+
style={{zIndex}}
240+
/>
241+
),
240242
[animation, backdropClassName, bsPrefix, zIndex]
241243
);
242244

@@ -254,16 +256,16 @@ const Modal = React.forwardRef(
254256
className={classNames(
255257
className,
256258
bsPrefix,
257-
animateStaticModal && `${bsPrefix}-static`
259+
animateStaticModal && `${bsPrefix}-static`,
260+
!animation && 'show'
258261
)}
259262
onClick={backdrop ? handleClick : undefined}
260263
onMouseUp={handleMouseUp}
264+
data-bs-theme={dataBsTheme}
261265
aria-label={ariaLabel}
262266
aria-labelledby={ariaLabelledby}
263267
aria-describedby={ariaDescribedby}
264268
>
265-
{/*
266-
// @ts-ignore */}
267269
<Dialog
268270
{...props}
269271
onMouseDown={handleDialogMouseDown}

0 commit comments

Comments
 (0)