feat: highlight problematic fields (#1330)

This commit is contained in:
Catalin Pit
2024-10-08 13:55:20 +03:00
committed by GitHub
parent cd3d9b701b
commit d40ed94b74
14 changed files with 158 additions and 68 deletions

View File

@ -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;
};