Skip to content

Commit

Permalink
Use better selector
Browse files Browse the repository at this point in the history
  • Loading branch information
amanda-anderson committed Oct 31, 2023
1 parent 221149a commit a11d21a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions front/app/components/Form/Components/Layouts/CLPageLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ const CLPageLayout = memo(
if (scrollToError) {
// Scroll to the first field with an error
document
.querySelectorAll('#error-display')[0]
.scrollIntoView({ behavior: 'smooth', block: 'center' });
.getElementById('error-display')
?.scrollIntoView({ behavior: 'smooth', block: 'center' });
setScrollToError(false);
}
}, [scrollToError]);
Expand Down
4 changes: 2 additions & 2 deletions front/app/components/Form/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,8 @@ const Form = memo(
if (scrollToError) {
// Scroll to the first field with an error
document
.querySelectorAll('#error-display')[0]
.scrollIntoView({ behavior: 'smooth', block: 'center' });
.getElementById('error-display')
?.scrollIntoView({ behavior: 'smooth', block: 'center' });
setScrollToError(false);
}
}, [scrollToError]);
Expand Down

0 comments on commit a11d21a

Please sign in to comment.