Fix: Modal Size gets cut in smaller screens. (#3441)
This commit is contained in:
parent
0a7bf6d0d3
commit
4781f1096c
|
|
@ -26,6 +26,7 @@ const Container = styled.div<{
|
|||
justify-content: center;
|
||||
align-items: center;
|
||||
& .${Classes.OVERLAY_CONTENT} {
|
||||
max-width: 95%;
|
||||
width: ${(props) => props.width}px;
|
||||
min-height: ${(props) => props.height}px;
|
||||
background: white;
|
||||
|
|
|
|||
|
|
@ -9,10 +9,13 @@ import {
|
|||
WidgetTypes,
|
||||
RenderMode,
|
||||
GridDefaults,
|
||||
MAIN_CONTAINER_WIDGET_ID,
|
||||
} from "constants/WidgetConstants";
|
||||
import { generateClassName } from "utils/generators";
|
||||
import * as Sentry from "@sentry/react";
|
||||
import withMeta, { WithMeta } from "./MetaHOC";
|
||||
import { AppState } from "reducers";
|
||||
import { getWidget } from "sagas/selectors";
|
||||
|
||||
const MODAL_SIZE: { [id: string]: { width: number; height: number } } = {
|
||||
MODAL_SMALL: {
|
||||
|
|
@ -72,6 +75,14 @@ export class ModalWidget extends BaseWidget<ModalWidgetProps, WidgetState> {
|
|||
canEscapeKeyClose: false,
|
||||
};
|
||||
|
||||
getModalWidth() {
|
||||
const widthFromOverlay = this.props.mainContainer.rightColumn * 0.95;
|
||||
const defaultModalWidth = MODAL_SIZE[this.props.size].width;
|
||||
return widthFromOverlay < defaultModalWidth
|
||||
? widthFromOverlay
|
||||
: defaultModalWidth;
|
||||
}
|
||||
|
||||
renderChildWidget = (childWidgetData: WidgetProps): ReactNode => {
|
||||
childWidgetData.parentId = this.props.widgetId;
|
||||
childWidgetData.shouldScrollContents = false;
|
||||
|
|
@ -82,7 +93,7 @@ export class ModalWidget extends BaseWidget<ModalWidgetProps, WidgetState> {
|
|||
childWidgetData.isVisible = this.props.isVisible;
|
||||
childWidgetData.containerStyle = "none";
|
||||
childWidgetData.minHeight = MODAL_SIZE[this.props.size].height;
|
||||
childWidgetData.rightColumn = MODAL_SIZE[this.props.size].width;
|
||||
childWidgetData.rightColumn = this.getModalWidth();
|
||||
return WidgetFactory.createWidget(childWidgetData, this.props.renderMode);
|
||||
};
|
||||
|
||||
|
|
@ -108,7 +119,7 @@ export class ModalWidget extends BaseWidget<ModalWidgetProps, WidgetState> {
|
|||
<ModalComponent
|
||||
isOpen={!!this.props.isVisible}
|
||||
onClose={this.closeModal}
|
||||
width={MODAL_SIZE[this.props.size].width}
|
||||
width={this.getModalWidth()}
|
||||
height={MODAL_SIZE[this.props.size].height}
|
||||
className={`t--modal-widget ${generateClassName(
|
||||
this.props.widgetId,
|
||||
|
|
@ -150,6 +161,7 @@ export interface ModalWidgetProps extends WidgetProps, WithMeta {
|
|||
canEscapeKeyClose?: boolean;
|
||||
shouldScrollContents?: boolean;
|
||||
size: string;
|
||||
mainContainer: WidgetProps;
|
||||
}
|
||||
|
||||
const mapDispatchToProps = (dispatch: any) => ({
|
||||
|
|
@ -169,8 +181,15 @@ const mapDispatchToProps = (dispatch: any) => ({
|
|||
});
|
||||
},
|
||||
});
|
||||
|
||||
const mapStateToProps = (state: AppState) => {
|
||||
const props = {
|
||||
mainContainer: getWidget(state, MAIN_CONTAINER_WIDGET_ID),
|
||||
};
|
||||
return props;
|
||||
};
|
||||
export default ModalWidget;
|
||||
export const ProfiledModalWidget = connect(
|
||||
null,
|
||||
mapStateToProps,
|
||||
mapDispatchToProps,
|
||||
)(Sentry.withProfiler(withMeta(ModalWidget)));
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user