Skip to content

Commit

Permalink
fix(ViewQuery-Modal): Copy icon is out of box when resize query modal (
Browse files Browse the repository at this point in the history
  • Loading branch information
paulo-eduardo authored Sep 3, 2022
1 parent 34a79ad commit 1cc2148
Showing 1 changed file with 28 additions and 20 deletions.
48 changes: 28 additions & 20 deletions superset-frontend/src/components/Modal/Modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
import React, { useRef, useState } from 'react';
import React, { useMemo, useRef, useState } from 'react';
import { isNil } from 'lodash';
import { styled, t } from '@superset-ui/core';
import { css } from '@emotion/react';
Expand Down Expand Up @@ -201,6 +201,24 @@ export const StyledModal = styled(BaseModal)<StyledModalProps>`
}
`}
`;
const defaultResizableConfig = (hideFooter: boolean | undefined) => ({
maxHeight: RESIZABLE_MAX_HEIGHT,
maxWidth: RESIZABLE_MAX_WIDTH,
minHeight: hideFooter
? RESIZABLE_MIN_HEIGHT
: RESIZABLE_MIN_HEIGHT + MODAL_FOOTER_HEIGHT,
minWidth: RESIZABLE_MIN_WIDTH,
enable: {
bottom: true,
bottomLeft: false,
bottomRight: true,
left: false,
top: false,
topLeft: false,
topRight: false,
right: true,
},
});

const CustomModal = ({
children,
Expand All @@ -222,24 +240,7 @@ const CustomModal = ({
wrapProps,
draggable = false,
resizable = false,
resizableConfig = {
maxHeight: RESIZABLE_MAX_HEIGHT,
maxWidth: RESIZABLE_MAX_WIDTH,
minHeight: hideFooter
? RESIZABLE_MIN_HEIGHT
: RESIZABLE_MIN_HEIGHT + MODAL_FOOTER_HEIGHT,
minWidth: RESIZABLE_MIN_WIDTH,
enable: {
bottom: true,
bottomLeft: false,
bottomRight: true,
left: false,
top: false,
topLeft: false,
topRight: false,
right: true,
},
},
resizableConfig = defaultResizableConfig(hideFooter),
draggableConfig,
destroyOnClose,
...rest
Expand Down Expand Up @@ -289,6 +290,13 @@ const CustomModal = ({
}
};

const getResizableConfig = useMemo(() => {
if (Object.keys(resizableConfig).length === 0) {
return defaultResizableConfig(hideFooter);
}
return resizableConfig;
}, [hideFooter, resizableConfig]);

const ModalTitle = () =>
draggable ? (
<div
Expand Down Expand Up @@ -329,7 +337,7 @@ const CustomModal = ({
{...draggableConfig}
>
{resizable ? (
<Resizable className="resizable" {...resizableConfig}>
<Resizable className="resizable" {...getResizableConfig}>
<div className="resizable-wrapper" ref={draggableRef}>
{modal}
</div>
Expand Down

0 comments on commit 1cc2148

Please sign in to comment.