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