Skip to content

Commit

Permalink
Enhance error list rendering: add smooth scroll and focus behavior fo…
Browse files Browse the repository at this point in the history
…r alert component

Refs: #7323
  • Loading branch information
deleonio committed Jan 29, 2025
1 parent de57a18 commit abeeb41
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion packages/components/src/components/form/shadow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,20 @@ export class KolForm implements FormAPI {

private renderErrorList(errorList?: ErrorListPropType[]): JSX.Element {
return (
<KolAlertFc class="kol-form__alert" type="error" variant="card" label={translate('kol-error-list-message')}>
<KolAlertFc
class="kol-form__alert"
ref={(el) => {
setTimeout(() => {
if (el && typeof el.focus === 'function') {
el.scrollIntoView({ behavior: 'smooth' });
el.focus();
}
}, 250);
}}
type="error"
variant="card"
label={translate('kol-error-list-message')}
>
<nav aria-label={translate('kol-error-list')}>
<ul>
{errorList?.map((error, index) => (
Expand Down

0 comments on commit abeeb41

Please sign in to comment.