Skip to content

Commit

Permalink
fix(Modal): Allow users to add classes to backdrop (#11015)
Browse files Browse the repository at this point in the history
We need to adjust the behavior in Virtual Assistant, but there's no way for us to target it specifically. This would let us pass a class down.
  • Loading branch information
rebeccaalpert authored Sep 24, 2024
1 parent c974f9b commit f6f8abb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
3 changes: 3 additions & 0 deletions packages/react-core/src/components/Modal/Modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ export interface ModalProps extends React.HTMLProps<HTMLDivElement>, OUIAProps {
children: React.ReactNode;
/** Additional classes added to the modal. */
className?: string;
/** Additional classes added to the modal backdrop. */
backdropClassName?: string;
/** Flag to disable focus trap. */
disableFocusTrap?: boolean;
/** The element to focus when the modal opens. By default the first
Expand Down Expand Up @@ -182,6 +184,7 @@ class Modal extends React.Component<ModalProps, ModalState> {
ouiaSafe={ouiaSafe}
position={position}
elementToFocus={elementToFocus}
backdropClassName={props.backdropClassName}
{...props}
/>,
container
Expand Down
5 changes: 4 additions & 1 deletion packages/react-core/src/components/Modal/ModalContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ export interface ModalContentProps extends OUIAProps {
children: React.ReactNode;
/** Additional classes added to the modal box. */
className?: string;
/** Additional classes added to the modal backdrop. */
backdropClassName?: string;
/** Flag to disable focus trap. */
disableFocusTrap?: boolean;
/** The element to focus when the modal opens. By default the first
Expand Down Expand Up @@ -47,6 +49,7 @@ export interface ModalContentProps extends OUIAProps {
}

export const ModalContent: React.FunctionComponent<ModalContentProps> = ({
backdropClassName,
children,
className,
isOpen = false,
Expand Down Expand Up @@ -106,7 +109,7 @@ export const ModalContent: React.FunctionComponent<ModalContentProps> = ({
</ModalBox>
);
return (
<Backdrop>
<Backdrop className={css(backdropClassName)}>
<FocusTrap
active={!disableFocusTrap}
focusTrapOptions={{
Expand Down

0 comments on commit f6f8abb

Please sign in to comment.