From 0f956866716421c93738102fa050bf47fac9472c Mon Sep 17 00:00:00 2001 From: Mahmoud Mortada Date: Fri, 8 Apr 2022 09:35:49 +0200 Subject: [PATCH] fix: add scrollbar to creat test form --- web/src/components/CreateTest/CreateTest.css | 32 ++- .../components/CreateTest/CreateTestModal.tsx | 227 +++++++++--------- 2 files changed, 142 insertions(+), 117 deletions(-) diff --git a/web/src/components/CreateTest/CreateTest.css b/web/src/components/CreateTest/CreateTest.css index 16a7832564..e3c96e04ed 100644 --- a/web/src/components/CreateTest/CreateTest.css +++ b/web/src/components/CreateTest/CreateTest.css @@ -1,3 +1,31 @@ +.test-modal { + overflow: hidden !important; + display: flex; +} + +.test-modal .ant-modal { + top: 50px; +} + +.test-modal .ant-modal-content { + height: min(calc(100vh - 16%), 620px); +} + +.test-modal .ant-modal-body { + position: absolute; + min-height: fit-content; + height: calc(100% - 110px); + width: 100%; + overflow-y: auto; +} + +.test-modal .ant-modal-footer { + position: absolute; + left: 0; + right: 0; + bottom: 0; +} + .method-select { } @@ -5,8 +33,8 @@ background-color: #fafafa !important; } -.method-select-item {} - +.method-select-item { +} .method-select-item .ant-select-item-option-selected { background-color: #fafafa !important; diff --git a/web/src/components/CreateTest/CreateTestModal.tsx b/web/src/components/CreateTest/CreateTestModal.tsx index c00871c10f..8a545d2636 100644 --- a/web/src/components/CreateTest/CreateTestModal.tsx +++ b/web/src/components/CreateTest/CreateTestModal.tsx @@ -1,22 +1,10 @@ import {useRef} from 'react'; -import {Modal as AntModal, Form, Input, Button, Select, Checkbox} from 'antd'; +import {Modal, Form, Input, Button, Select, Checkbox} from 'antd'; import {DeleteOutlined} from '@ant-design/icons'; -import styled from 'styled-components'; import {useCreateTestMutation} from 'services/TestService'; import {HTTP_METHOD} from 'types'; import './CreateTest.css'; -const Modal = styled(AntModal)` - .ant-modal { - width: 100%; - max-width: unset; - margin: unset; - } - .ant-modal-centered::before { - content: unset; - } -`; - interface IProps { visible: boolean; onClose: () => void; @@ -56,115 +44,124 @@ const CreateTestModal = ({visible, onClose}: IProps): JSX.Element => { }; return ( - -
-
- - - + +
+ +
+ + + - - - -
+ + + +
- - - + + + - -
- - {(fields, {add, remove}) => ( - <> - {fields.map((field, index) => ( -
- - - + +
+ + {(fields, {add, remove}) => ( + <> + {fields.map((field, index) => ( +
+ + + - - { - if (!touchedHttpHeadersRef.current[field.name]) { - touchedHttpHeadersRef.current[field.name] = true; - const headers = form.getFieldsValue().headersList; - headers[field.name].checked = true; - form.setFieldsValue({headersList: headers}); - } + + { + if (!touchedHttpHeadersRef.current[field.name]) { + touchedHttpHeadersRef.current[field.name] = true; + const headers = form.getFieldsValue().headersList; + headers[field.name].checked = true; + form.setFieldsValue({headersList: headers}); + } - if (fields.length - 1 === index) { - add({checked: false}); - } - }} - /> - - - { - if (!touchedHttpHeadersRef.current[field.name]) { - touchedHttpHeadersRef.current[field.name] = true; - const headers = form.getFieldsValue().headersList; - headers[field.name].checked = true; - form.setFieldsValue({headersList: headers}); - } + if (fields.length - 1 === index) { + add({checked: false}); + } + }} + /> + + + { + if (!touchedHttpHeadersRef.current[field.name]) { + touchedHttpHeadersRef.current[field.name] = true; + const headers = form.getFieldsValue().headersList; + headers[field.name].checked = true; + form.setFieldsValue({headersList: headers}); + } - if (fields.length - 1 === index) { - add({checked: false}); - } - }} - /> - + if (fields.length - 1 === index) { + add({checked: false}); + } + }} + /> + - -
- ))} - - )} -
-
-
- - - - + +
+ ))} + + )} +
+
+
+ + + + +
); };