Fix error when trying to scroll to an invalid field
This commit is contained in:
parent
9da641f848
commit
ee452f75fe
|
@ -423,10 +423,14 @@
|
||||||
}
|
}
|
||||||
const fieldId = field.fieldState.fieldId
|
const fieldId = field.fieldState.fieldId
|
||||||
const fieldElement = document.getElementById(fieldId)
|
const fieldElement = document.getElementById(fieldId)
|
||||||
fieldElement.focus({ preventScroll: true })
|
if (fieldElement) {
|
||||||
|
fieldElement.focus({ preventScroll: true })
|
||||||
|
}
|
||||||
const label = document.querySelector(`label[for="${fieldId}"]`)
|
const label = document.querySelector(`label[for="${fieldId}"]`)
|
||||||
label.style.scrollMargin = "100px"
|
if (label) {
|
||||||
label.scrollIntoView({ behavior: "smooth", block: "nearest" })
|
label.style.scrollMargin = "100px"
|
||||||
|
label.scrollIntoView({ behavior: "smooth", block: "nearest" })
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Action context to pass to children
|
// Action context to pass to children
|
||||||
|
|
Loading…
Reference in New Issue