Skip to content

Commit d25d2fe

Browse files
committed
Moved scrollIntoView into correct place.
1 parent 1fc10dd commit d25d2fe

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

src/lib/client/formEnhance.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -230,12 +230,10 @@ export function formEnhance<T extends AnyZodObject, M>(
230230
? (document.querySelector(options.stickyNavbar) as HTMLElement)
231231
: null;
232232

233-
if (!isElementInViewport(el, nav?.offsetHeight ?? 0)) {
234-
if (typeof options.scrollToError == 'string') {
235-
scrollToAndCenter(el, undefined, options.scrollToError);
236-
} else {
237-
el.scrollIntoView(options.scrollToError);
238-
}
233+
if (typeof options.scrollToError != 'string') {
234+
el.scrollIntoView(options.scrollToError);
235+
} else if (!isElementInViewport(el, nav?.offsetHeight ?? 0)) {
236+
scrollToAndCenter(el, undefined, options.scrollToError);
239237
}
240238

241239
// Don't focus on the element if on mobile, it will open the keyboard

0 commit comments

Comments
 (0)