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

[core] feat(MultiStepDialog): allow multiple close buttons #5762

Merged
merged 1 commit into from
Nov 30, 2022
Merged
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
18 changes: 6 additions & 12 deletions packages/core/src/components/dialog/multistepDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export interface IMultistepDialogProps extends DialogProps {
children?: React.ReactNode;

/**
* Props for the close button that appears in the footer when there is no title.
* Props for the close button that appears in the footer.
*/
closeButtonProps?: DialogStepButtonProps;

Expand Down Expand Up @@ -79,9 +79,8 @@ export interface IMultistepDialogProps extends DialogProps {
resetOnClose?: boolean;

/**
* Whether the footer close button is shown. The button will only appear if
* `isCloseButtonShown` is `true`. The close button in the dialog title will
* not be shown when this is `true`.
* Whether the footer close button is shown. When this value is true, the button will appear
* regardless of the value of `isCloseButtonShown`.
*
* @default false
*/
Expand Down Expand Up @@ -121,13 +120,9 @@ export class MultistepDialog extends AbstractPureComponent2<MultistepDialogProps
const { className, navigationPosition, showCloseButtonInFooter, isCloseButtonShown, ...otherProps } =
this.props;

// Only one close button should be displayed. If the footer close button
// is shown, we need to ensure the dialog close button is not displayed.
const isCloseButtonVisible = !showCloseButtonInFooter && isCloseButtonShown;

return (
<Dialog
isCloseButtonShown={isCloseButtonVisible}
isCloseButtonShown={isCloseButtonShown}
{...otherProps}
className={classNames(
{
Expand Down Expand Up @@ -211,9 +206,8 @@ export class MultistepDialog extends AbstractPureComponent2<MultistepDialogProps
}

private renderFooter() {
const { closeButtonProps, isCloseButtonShown, showCloseButtonInFooter, onClose } = this.props;
const isFooterCloseButtonVisible = showCloseButtonInFooter && isCloseButtonShown;
const maybeCloseButton = !isFooterCloseButtonVisible ? undefined : (
const { closeButtonProps, showCloseButtonInFooter, onClose } = this.props;
const maybeCloseButton = !showCloseButtonInFooter ? undefined : (
<DialogStepButton text="Close" onClick={onClose} {...closeButtonProps} />
);
return (
Expand Down