Skip to content

Commit 35b176c

Browse files
siddhant1Siddhant
authored andcommitted
scroll form when the error happens (DP) (#25760)
* scroll when the error happens * description editor update * fix errors * locate --------- Co-authored-by: Siddhant <siddhant@MacBook-Pro.local>
1 parent 59b8d21 commit 35b176c

File tree

6 files changed

+60
-31
lines changed

6 files changed

+60
-31
lines changed

openmetadata-ui/src/main/resources/ui/src/components/DataQuality/AddDataQualityTest/components/TestCaseFormV1.less

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,13 @@
9595
font-weight: @font-semibold;
9696
margin-bottom: 0px;
9797
}
98+
9899
.card-title-description {
99100
color: @grey-600;
100101
margin-bottom: @margin-mlg;
101102
}
102103
}
104+
103105
.schedule-interval-v1 {
104106
.cron-expression-card {
105107
.ant-card-body {
@@ -174,6 +176,7 @@
174176

175177
.bar-menu-wrapper {
176178
padding: @size-xxs;
179+
177180
.bar-menu-wrapper--format--button--icon {
178181
width: @size-mlg;
179182
height: @size-mlg;

openmetadata-ui/src/main/resources/ui/src/components/Domain/AddDomainForm/AddDomainForm.component.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ import {
4343
} from '../../common/IconPicker';
4444
import '../domain.less';
4545
import { DomainFormType } from '../DomainPage.interface';
46-
import './add-domain-form.less';
4746
import { AddDomainFormProps } from './AddDomainForm.interface';
4847

4948
const AddDomainForm = ({
@@ -173,7 +172,7 @@ const AddDomainForm = ({
173172
'data-testid': 'description',
174173
initialValue: '',
175174
height: 'auto',
176-
className: 'add-domain-form-description',
175+
className: 'add-domain-form-description new-form-style',
177176
},
178177
},
179178
{

openmetadata-ui/src/main/resources/ui/src/components/Domain/AddDomainForm/add-domain-form.less

Lines changed: 0 additions & 21 deletions
This file was deleted.

openmetadata-ui/src/main/resources/ui/src/components/common/atoms/drawer/useDrawerBody.tsx

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ export interface DrawerBodyConfig {
1919
loading?: boolean;
2020
loadingMessage?: string;
2121
padding?: number | string;
22+
className?: string;
2223
sx?: any;
2324
}
2425

@@ -53,7 +54,14 @@ export interface DrawerBodyConfig {
5354
* ```
5455
*/
5556
export const useDrawerBody = (config: DrawerBodyConfig = {}) => {
56-
const { children, loading, loadingMessage, padding = 6, sx = {} } = config;
57+
const {
58+
children,
59+
loading,
60+
loadingMessage,
61+
padding = 6,
62+
className,
63+
sx = {},
64+
} = config;
5765

5866
const drawerBody = useMemo(
5967
() => (
@@ -88,6 +96,7 @@ export const useDrawerBody = (config: DrawerBodyConfig = {}) => {
8896
</Box>
8997
)}
9098
<Box
99+
className={className}
91100
sx={{
92101
overflow: 'auto',
93102
height: '100%',
@@ -97,7 +106,7 @@ export const useDrawerBody = (config: DrawerBodyConfig = {}) => {
97106
</Box>
98107
</Box>
99108
),
100-
[children, loading, loadingMessage, padding, sx]
109+
[children, loading, loadingMessage, padding, className, sx]
101110
);
102111

103112
return {

openmetadata-ui/src/main/resources/ui/src/components/common/atoms/drawer/useFormDrawer.tsx

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@
1111
* limitations under the License.
1212
*/
1313

14-
import React, { ReactNode, useCallback, useState } from 'react';
14+
import classNames from 'classnames';
15+
import React, { ReactNode, useCallback, useMemo, useState } from 'react';
1516
import { useTranslation } from 'react-i18next';
17+
import { createScrollToErrorHandler } from '../../../../utils/formUtils';
1618
import {
1719
CompositeDrawerConfig,
1820
useCompositeDrawer,
@@ -108,9 +110,10 @@ export const useFormDrawer = <T,>(config: FormDrawerConfig<T>) => {
108110
...header,
109111
},
110112
body: {
113+
...body,
111114
children: form,
112115
loading: loading || isSubmitting,
113-
...body,
116+
className: classNames('drawer-form-content', body?.className),
114117
},
115118
footer: {
116119
align: footerAlign,
@@ -183,11 +186,18 @@ export const useFormDrawerWithRef = <T,>(
183186
) => {
184187
const { formRef, onSubmit, ...restConfig } = config;
185188

189+
const scrollToError = useMemo(() => createScrollToErrorHandler(), []);
190+
186191
const handleSubmit = useCallback(async () => {
187192
if (formRef?.validateFields) {
188-
// Validate first
189-
const values = await formRef.validateFields();
190-
// If validation passes, submit the form
193+
let values: T;
194+
try {
195+
values = await formRef.validateFields();
196+
} catch {
197+
scrollToError();
198+
199+
return;
200+
}
191201
if (formRef?.submit) {
192202
formRef.submit();
193203
} else {
@@ -198,7 +208,7 @@ export const useFormDrawerWithRef = <T,>(
198208
} else {
199209
await onSubmit({} as T);
200210
}
201-
}, [formRef, onSubmit]);
211+
}, [formRef, onSubmit, scrollToError]);
202212

203213
const drawer = useFormDrawer({
204214
...restConfig,

openmetadata-ui/src/main/resources/ui/src/styles/components/form.less

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,20 +25,23 @@
2525
.form-item-horizontal {
2626
.ant-form-item-row {
2727
flex-direction: row;
28+
2829
.ant-form-item-label {
2930
display: block;
3031
flex: 0 0 40%;
3132
max-width: 40%;
3233
padding: 0px;
3334
align-self: center;
3435
}
36+
3537
.ant-form-item-control {
3638
display: block;
3739
flex: 0 0 60%;
3840
max-width: 60%;
3941
}
4042
}
4143
}
44+
4245
.form-item-vertical {
4346
.ant-form-item-row {
4447
flex-direction: column;
@@ -82,12 +85,14 @@
8285
border-color: @primary-5;
8386
}
8487
}
88+
8589
.block-editor-wrapper.block-editor-wrapper--bar-menu {
8690
.bar-menu-wrapper {
8791
border-top-left-radius: @border-rad-xs;
8892
border-top-right-radius: @border-rad-xs;
8993
border-color: @grey-300;
9094
}
95+
9196
.om-block-editor {
9297
border-bottom-left-radius: @border-rad-xs;
9398
border-bottom-right-radius: @border-rad-xs;
@@ -103,10 +108,12 @@
103108
.ant-switch-checked {
104109
background-color: @primary-6;
105110
}
111+
106112
.ant-switch-checked .ant-switch-handle::before,
107113
.ant-switch-handle::before {
108114
background-color: @white;
109115
}
116+
110117
.form-switch-container .ant-typography,
111118
.ant-form-item-label > label,
112119
.form-label-title {
@@ -119,6 +126,7 @@
119126
.ant-form-item-label > label.ant-form-item-required::before {
120127
display: none;
121128
}
129+
122130
.ant-form-item-label > label.ant-form-item-required::after {
123131
display: inline-block;
124132
margin-left: 4px;
@@ -128,4 +136,25 @@
128136
line-height: 1;
129137
content: '*';
130138
}
139+
140+
.block-editor-wrapper {
141+
.om-block-editor {
142+
background-color: @white;
143+
max-height: 120px;
144+
padding: @size-sm;
145+
146+
p:last-child {
147+
padding-bottom: 75px;
148+
}
149+
}
150+
151+
.bar-menu-wrapper {
152+
padding: @size-xxs;
153+
154+
.bar-menu-wrapper--format--button--icon {
155+
width: @size-mlg;
156+
height: @size-mlg;
157+
}
158+
}
159+
}
131160
}

0 commit comments

Comments
 (0)