mirror of
https://github.com/documenso/documenso.git
synced 2025-11-12 07:43:16 +10:00
feat: highlight problematic fields (#1330)
This commit is contained in:
@ -39,3 +39,27 @@ export const validateFieldsInserted = (fields: Field[]): boolean => {
|
||||
|
||||
return uninsertedFields.length === 0;
|
||||
};
|
||||
|
||||
export const validateFieldsUninserted = (): boolean => {
|
||||
const fieldCardElements = document.getElementsByClassName('react-draggable');
|
||||
|
||||
const errorElements: HTMLElement[] = [];
|
||||
|
||||
Array.from(fieldCardElements).forEach((element) => {
|
||||
const innerDiv = element.querySelector('div');
|
||||
const hasError = innerDiv?.getAttribute('data-error') === 'true';
|
||||
|
||||
if (hasError) {
|
||||
errorElements.push(element as HTMLElement);
|
||||
} else {
|
||||
element.removeAttribute('data-error');
|
||||
}
|
||||
});
|
||||
|
||||
if (errorElements.length > 0) {
|
||||
errorElements[0].scrollIntoView({ behavior: 'smooth', block: 'center' });
|
||||
return false;
|
||||
}
|
||||
|
||||
return errorElements.length === 0;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user