@@ -0,0 +1,12 @@
|
||||
export function focusFormError(id: string): boolean {
|
||||
const target = document.getElementById(id);
|
||||
if (!target) return false;
|
||||
let ancestor = target.parentElement;
|
||||
while (ancestor) {
|
||||
if (ancestor.tagName === 'DETAILS') ancestor.setAttribute('open', '');
|
||||
ancestor = ancestor.parentElement;
|
||||
}
|
||||
target.focus();
|
||||
target.scrollIntoView({ block: 'center', behavior: 'auto' });
|
||||
return true;
|
||||
}
|
||||
Reference in New Issue
Block a user