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 #3432: Dialog maximized restore scrollbar #3434

Merged
merged 1 commit into from
Oct 7, 2022
Merged
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
78 changes: 40 additions & 38 deletions components/lib/dialog/Dialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -291,13 +291,15 @@ export const Dialog = React.forwardRef((props, ref) => {
const disableDocumentSettings = () => {
unbindGlobalListeners();

const isMaximized = props.maximizable && maximized;

if (props.modal) {
let hasBlockScroll = document.primeDialogParams && document.primeDialogParams.some((param) => param.hasBlockScroll);
const hasBlockScroll = document.primeDialogParams && document.primeDialogParams.some((param) => param.hasBlockScroll);

if (hasBlockScroll) {
if (hasBlockScroll || isMaximized) {
DomHandler.removeClass(document.body, 'p-overflow-hidden');
}
} else if (props.blockScroll || (props.maximizable && maximized)) {
} else if (props.blockScroll || isMaximized) {
DomHandler.removeClass(document.body, 'p-overflow-hidden');
}
};
Expand Down Expand Up @@ -560,49 +562,49 @@ export const Dialog = React.forwardRef((props, ref) => {
Dialog.displayName = 'Dialog';
Dialog.defaultProps = {
__TYPE: 'Dialog',
id: null,
header: null,
footer: null,
visible: false,
position: 'center',
draggable: true,
resizable: true,
modal: true,
onHide: null,
onShow: null,
headerStyle: null,
headerClassName: null,
contentStyle: null,
contentClassName: null,
closeOnEscape: true,
dismissableMask: false,
rtl: false,
closable: true,
style: null,
className: null,
maskStyle: null,
maskClassName: null,
showHeader: true,
appendTo: null,
ariaCloseIconLabel: null,
baseZIndex: 0,
maximizable: false,
blockScroll: false,
icons: null,
ariaCloseIconLabel: null,
breakpoints: null,
className: null,
closable: true,
closeOnEscape: true,
contentClassName: null,
contentStyle: null,
dismissableMask: false,
draggable: true,
focusOnShow: true,
minX: 0,
minY: 0,
footer: null,
header: null,
headerClassName: null,
headerStyle: null,
icons: null,
id: null,
keepInViewport: true,
maskClassName: null,
maskStyle: null,
maximizable: false,
maximized: false,
breakpoints: null,
transitionOptions: null,
onMaximize: null,
onDragStart: null,
minX: 0,
minY: 0,
modal: true,
onClick: null,
onDrag: null,
onDragEnd: null,
onResizeStart: null,
onDragStart: null,
onHide: null,
onMaskClick: null,
onMaximize: null,
onResize: null,
onResizeEnd: null,
onClick: null,
onMaskClick: null
onResizeStart: null,
onShow: null,
position: 'center',
resizable: true,
rtl: false,
showHeader: true,
style: null,
transitionOptions: null,
visible: false
};
68 changes: 34 additions & 34 deletions components/lib/dialog/dialog.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,52 +17,52 @@ interface DialogMaximizeParams {
}

export interface DialogProps {
id?: string;
header?: DialogTemplateType;
footer?: DialogTemplateType;
visible?: boolean;
position?: DialogPositionType;
draggable?: boolean;
resizable?: boolean;
modal?: boolean;
headerStyle?: object;
headerClassName?: string;
contentStyle?: object;
contentClassName?: string;
closeOnEscape?: boolean;
dismissableMask?: boolean;
rtl?: boolean;
closable?: boolean;
style?: object;
className?: string;
maskStyle?: object;
maskClassName?: string;
showHeader?: boolean;
appendTo?: DialogAppendToType;
ariaCloseIconLabel?: string;
baseZIndex?: number;
maximizable?: boolean;
blockScroll?: boolean;
icons?: DialogTemplateType;
ariaCloseIconLabel?: string;
breakpoints?: DialogBreakpoints;
children?: React.ReactNode;
className?: string;
closable?: boolean;
closeOnEscape?: boolean;
contentClassName?: string;
contentStyle?: object;
dismissableMask?: boolean;
draggable?: boolean;
focusOnShow?: boolean;
minX?: number;
minY?: number;
footer?: DialogTemplateType;
header?: DialogTemplateType;
headerClassName?: string;
headerStyle?: object;
icons?: DialogTemplateType;
id?: string;
keepInViewport?: boolean;
maskClassName?: string;
maskStyle?: object;
maximizable?: boolean;
maximized?: boolean;
breakpoints?: DialogBreakpoints;
minX?: number;
minY?: number;
modal?: boolean;
position?: DialogPositionType;
resizable?: boolean;
rtl?: boolean;
showHeader?: boolean;
style?: object;
transitionOptions?: CSSTransitionProps;
onMaximize?(e: DialogMaximizeParams): void;
onDragStart?(e: React.DragEvent<HTMLElement>): void;
visible?: boolean;
onClick?(e: React.MouseEvent<HTMLElement>): void;
onDrag?(e: React.DragEvent<HTMLElement>): void;
onDragEnd?(e: React.DragEvent<HTMLElement>): void;
onResizeStart?(e: React.MouseEvent<HTMLElement>): void;
onDragStart?(e: React.DragEvent<HTMLElement>): void;
onHide(): void;
onMaskClick?(e: React.MouseEvent<HTMLElement>): void;
onMaximize?(e: DialogMaximizeParams): void;
onResize?(e: React.MouseEvent<HTMLElement>): void;
onResizeEnd?(e: React.MouseEvent<HTMLElement>): void;
onHide(): void;
onResizeStart?(e: React.MouseEvent<HTMLElement>): void;
onShow?(): void;
onMaskClick?(e: React.MouseEvent<HTMLElement>): void;
onClick?(e: React.MouseEvent<HTMLElement>): void;
children?: React.ReactNode;
}

export declare class Dialog extends React.Component<DialogProps, any> {
Expand Down