Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(Modal, Dialog, Alert): adding modal props to Dialog and pass enableBackgroundUI #7167

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/__internal__/popover/popover.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ test("when mounted, renders popup in the reference's nearest dialog ancestor if
const buttonRef = React.useRef<HTMLButtonElement>(null);

return (
<Dialog open>
<Dialog open enableBackgroundUI={false}>
<button
ref={buttonRef}
type="button"
Expand Down
7 changes: 6 additions & 1 deletion src/components/action-popover/action-popover.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -728,7 +728,12 @@ OpeningAModal.storyName = "Opening a Modal";
export const ActionPopoverNestedInDialog: Story = () => {
const [isOpen, setIsOpen] = useState(true);
return (
<Dialog open={isOpen} onCancel={() => setIsOpen(false)} title="Dialog">
<Dialog
open={isOpen}
onCancel={() => setIsOpen(false)}
title="Dialog"
enableBackgroundUI={false}
>
<ActionPopover>
<ActionPopoverItem icon="email" onClick={() => {}}>
Email Invoice
Expand Down
7 changes: 6 additions & 1 deletion src/components/action-popover/components.test-pw.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1255,7 +1255,12 @@ export const SubmenuPositionedRight = () => {
export const ActionPopoverNestedInDialog = () => {
const [isOpen, setIsOpen] = useState(true);
return (
<Dialog open={isOpen} onCancel={() => setIsOpen(false)} title="Dialog">
<Dialog
open={isOpen}
onCancel={() => setIsOpen(false)}
title="Dialog"
enableBackgroundUI={false}
>
<ActionPopover>
<ActionPopoverItem icon="email" onClick={() => {}}>
Email Invoice
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ export const AdvancedColorPicker = ({
focusFirstElement={selectedColorRef}
role={role}
restoreFocusOnClose={restoreFocusOnClose}
enableBackgroundUI={false}
>
<StyledAdvancedColorPickerPreview
data-element="color-picker-preview"
Expand Down
2 changes: 2 additions & 0 deletions src/components/alert/alert-test.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ export const DefaultStory = ({
<>
<Button onClick={handleOpen}>Open Alert</Button>
<Alert
enableBackgroundUI={false}
onCancel={handleCancel}
open={isOpen}
title={title}
Expand Down Expand Up @@ -103,6 +104,7 @@ export const AlertComponentTest = ({
showCloseIcon
size="extra-small"
open={isOpen}
enableBackgroundUI={false}
{...props}
>
{children}
Expand Down
1 change: 1 addition & 0 deletions src/components/alert/alert.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export const Default: Story = () => {
showCloseIcon
size="extra-small"
open={isOpen}
enableBackgroundUI={false}
>
This is an example of an alert
</Alert>
Expand Down
4 changes: 4 additions & 0 deletions src/components/alert/alert.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const ControlledAlert = ({ onCancel, ...rest }: Partial<AlertProps>) => {
<Alert
{...rest}
open={open}
enableBackgroundUI={false}
onCancel={(ev) => {
setOpen(false);
onCancel?.(ev);
Expand All @@ -24,6 +25,7 @@ test("include correct component, element and role data tags", () => {
<Alert
open
onCancel={() => undefined}
enableBackgroundUI={false}
title="Alert title"
subtitle="Alert Subtitle"
data-element="bar"
Expand All @@ -48,6 +50,7 @@ test("has the expected border radius styling", () => {
<Alert
open
onCancel={() => undefined}
enableBackgroundUI={false}
title="Alert title"
subtitle="Alert Subtitle"
data-element="bar"
Expand All @@ -69,6 +72,7 @@ test("should allow custom data props on close button to be assigned", () => {
<Alert
open
onCancel={() => undefined}
enableBackgroundUI={false}
title="Alert title"
subtitle="Alert Subtitle"
data-element="bar"
Expand Down
2 changes: 2 additions & 0 deletions src/components/alert/components.test-pw.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export const AlertComponent = ({
showCloseIcon
size="extra-small"
open={isOpen}
enableBackgroundUI={false}
{...props}
>
{children}
Expand Down Expand Up @@ -55,6 +56,7 @@ export const TopModalOverride = () => {
onCancel={() => setIsOpenAlert(false)}
title="Alert"
topModalOverride
enableBackgroundUI={false}
>
<Textbox label="Alert textbox" />
</Alert>
Expand Down
1 change: 1 addition & 0 deletions src/components/confirm/confirm.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ export const Confirm = ({
size={size}
showCloseIcon={showCloseIcon}
topModalOverride={topModalOverride}
enableBackgroundUI={false}
{...ariaProps}
{...rest}
>
Expand Down
7 changes: 6 additions & 1 deletion src/components/date/components.test-pw.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,12 @@ export const DateInputInsideDialog = ({
};

return (
<Dialog open={isOpen} onCancel={() => setIsOpen(false)} title="Dialog">
<Dialog
open={isOpen}
onCancel={() => setIsOpen(false)}
title="Dialog"
enableBackgroundUI={false}
>
<DateInput
label="Date"
name="date-input"
Expand Down
8 changes: 7 additions & 1 deletion src/components/dialog-full-screen/components.test-pw.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ export const NestedDialog = () => {
open={nestedDialogOpen}
onCancel={handleNestedDialogCancel}
title={nestedDialogTitle}
enableBackgroundUI={false}
>
Nested Dialog Content
</Dialog>
Expand Down Expand Up @@ -117,7 +118,11 @@ export const MultipleDialogsInDifferentProviders = () => {
</CarbonProvider>
<CarbonProvider>
<Box>
<Dialog open={isModal2Open} onCancel={() => setIsModal2Open(false)}>
<Dialog
open={isModal2Open}
onCancel={() => setIsModal2Open(false)}
enableBackgroundUI={false}
>
This is Modal 2
</Dialog>
</Box>
Expand Down Expand Up @@ -951,6 +956,7 @@ export const TopModalOverride = () => {
open={isOpenDialog}
onCancel={() => setIsOpenDialog(false)}
title="Dialog"
enableBackgroundUI={false}
>
<Textbox label="Dialog textbox" />
</Dialog>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ export const Nested: StoryType = () => {
open={nestedDialogOpen}
onCancel={handleNestedDialogCancel}
title="Nested Dialog"
enableBackgroundUI={false}
>
Nested Dialog Content
</Dialog>
Expand Down
40 changes: 36 additions & 4 deletions src/components/dialog/components.test-pw.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export const DialogComponent = (props: Partial<DialogProps>) => {
return (
<Dialog
open={isOpen}
enableBackgroundUI={false}
title="My dialog"
showCloseIcon
onCancel={() => setIsOpen(false)}
Expand All @@ -45,7 +46,13 @@ export const DialogWithFirstFocusableElement = (
const ref = useRef<HTMLButtonElement>(null);

return (
<Dialog open title="My dialog" focusFirstElement={ref} {...props}>
<Dialog
open
title="My dialog"
focusFirstElement={ref}
{...props}
enableBackgroundUI={false}
>
<Button ref={ref} onClick={() => {}}>
Press me
</Button>
Expand All @@ -68,7 +75,7 @@ export const DialogWithToast = () => {
>
Toast message 1
</Toast>
<Dialog open title="My dialog">
<Dialog open title="My dialog" enableBackgroundUI={false}>
<Button onClick={() => setOpenToast(true)}>Open Toast</Button>
</Dialog>
</>
Expand All @@ -81,7 +88,12 @@ export const DialogBackgroundScrollTest = () => {
<Box height="100px" position="absolute" bottom="0px">
I should not be scrolled into view
</Box>
<Dialog open title="My dialog" onCancel={() => {}}>
<Dialog
open
title="My dialog"
onCancel={() => {}}
enableBackgroundUI={false}
>
<Textbox label="textbox" />
</Dialog>
</Box>
Expand All @@ -101,6 +113,7 @@ export const DialogWithOpenToastsBackgroundScrollTest = () => {
title="My dialog"
onCancel={() => {}}
focusableContainers={[toast1Ref, toast2Ref]}
enableBackgroundUI={false}
>
<Textbox label="textbox" />
</Dialog>
Expand Down Expand Up @@ -139,6 +152,7 @@ export const TopModalOverride = () => {
onCancel={() => setIsOpenDialog(false)}
title="Dialog"
topModalOverride
enableBackgroundUI={false}
>
<Textbox label="Dialog textbox" />
</Dialog>
Expand All @@ -155,7 +169,12 @@ export const TopModalOverride = () => {

export const DialogWithAutoFocusSelect = () => {
return (
<Dialog open title="My dialog" onCancel={() => {}}>
<Dialog
open
title="My dialog"
onCancel={() => {}}
enableBackgroundUI={false}
>
<Select autoFocus label="select">
<Option value="1" text="one" />
</Select>
Expand All @@ -180,6 +199,7 @@ export const DialogComponentFocusableSelectors = (
focusableContainers={[toastRef]}
focusableSelectors={CUSTOM_SELECTOR}
{...props}
enableBackgroundUI={false}
>
<Box className="focusable-container">
<Textbox label="First Name" />
Expand Down Expand Up @@ -227,6 +247,7 @@ export const DefaultStory = ({
title="Title"
subtitle="Subtitle"
restoreFocusOnClose={restoreFocusOnClose}
enableBackgroundUI={false}
>
<Form
stickyFooter
Expand Down Expand Up @@ -273,6 +294,7 @@ export const DefaultNestedStory = () => {
open={isFirstDialogOpen}
onCancel={() => setIsFirstDialogOpen(false)}
title="First Dialog"
enableBackgroundUI={false}
>
<Button onClick={() => setIsNestedDialogOpen(true)}>
Open Nested Dialog
Expand All @@ -281,6 +303,7 @@ export const DefaultNestedStory = () => {
open={isNestedDialogOpen}
onCancel={() => setIsNestedDialogOpen(false)}
title="Nested Dialog"
enableBackgroundUI={false}
>
<Textbox label="Nested Dialog Textbox" />
</Dialog>
Expand All @@ -301,6 +324,7 @@ export const Editable = () => {
open={isOpen}
onCancel={() => setIsOpen(false)}
title="Add an address"
enableBackgroundUI={false}
>
<Form
stickyFooter
Expand Down Expand Up @@ -366,6 +390,7 @@ export const WithHelp = () => {
onCancel={() => setIsOpen(false)}
title="Add an address"
help="Some help text"
enableBackgroundUI={false}
>
<Form
stickyFooter
Expand Down Expand Up @@ -414,6 +439,7 @@ export const LoadingContent = () => {
open={isOpen}
title="Dialog with dynamic content"
onCancel={() => setIsOpen(false)}
enableBackgroundUI={false}
>
{isLoading ? (
<Loader isActive isInsideButton={false} size="small" />
Expand Down Expand Up @@ -447,6 +473,7 @@ export const FocusingADifferentFirstElement = () => {
open={isOpenOne}
onCancel={() => setIsOpenOne(false)}
aria-label="Demo using focusFirstElement"
enableBackgroundUI={false}
>
<Typography>
Focus an element that does not support autofocus
Expand All @@ -472,6 +499,7 @@ export const FocusingADifferentFirstElement = () => {
open={isOpenTwo}
onCancel={() => setIsOpenTwo(false)}
aria-label="Demo using autoFocus"
enableBackgroundUI={false}
>
<Typography>Focus an element that supports autoFocus</Typography>
<Box
Expand Down Expand Up @@ -500,6 +528,7 @@ export const OverridingContentPadding = () => {
title="Title"
subtitle="Subtitle"
contentPadding={{ p: 0 }}
enableBackgroundUI={false}
>
<Form
stickyFooter
Expand Down Expand Up @@ -549,6 +578,7 @@ export const OtherFocusableContainers = () => {
title="Title"
subtitle="Subtitle"
focusableContainers={[toast1Ref, toast2Ref]}
enableBackgroundUI={false}
>
<Form
stickyFooter
Expand Down Expand Up @@ -620,6 +650,7 @@ export const Responsive = () => {
onCancel={() => setIsOpen(false)}
title="Title"
subtitle="Subtitle"
enableBackgroundUI={false}
>
<Form
stickyFooter
Expand Down Expand Up @@ -668,6 +699,7 @@ export const UsingHandle = () => {
title={isSubmitted ? "Thank you for your feedback." : "Give feedback"}
showCloseIcon
ref={dialogHandle}
enableBackgroundUI={false}
>
{isSubmitted ? (
<Typography>
Expand Down
Loading
Loading