diff --git a/src/core_modules/capture-core/components/DataEntry/dataEntryField/internal/DataEntryField.component.tsx b/src/core_modules/capture-core/components/DataEntry/dataEntryField/internal/DataEntryField.component.tsx index f9b8e9e624..ec5933ad19 100644 --- a/src/core_modules/capture-core/components/DataEntry/dataEntryField/internal/DataEntryField.component.tsx +++ b/src/core_modules/capture-core/components/DataEntry/dataEntryField/internal/DataEntryField.component.tsx @@ -19,12 +19,7 @@ class DataEntryFieldPlain extends React.Component { goto() { if (this.gotoInstance) { - this.gotoInstance.scrollIntoView(); - - const scrolledY = window.scrollY; - if (scrolledY) { - window.scroll(0, scrolledY - 48); - } + this.gotoInstance.scrollIntoView({ block: 'start' }); } } @@ -60,6 +55,7 @@ class DataEntryFieldPlain extends React.Component { ref={(gotoInstance) => { this.gotoInstance = gotoInstance; }} key={propName} data-test={`dataentry-field-${propName}`} + style={{ scrollMarginTop: '80px' }} > - (InnerComponent: React.ComponentType) => { + (InnerComponent: React.ComponentType) => class GotoFieldInterface extends React.Component { gotoInstance: any; goto() { if (this.gotoInstance) { - this.gotoInstance.scrollIntoView(); - - const scrolledY = window.scrollY; - if (scrolledY) { - // TODO: Set the modifier some other way (caused be the fixed header) - window.scroll(0, scrolledY - 48); - } + this.gotoInstance.scrollIntoView({ block: 'start' }); } } render() { - const { forwardedRef, ...rest } = this.props; return (
{ this.gotoInstance = gotoInstance; }} + style={{ scrollMarginTop: '80px' }} >
); } - } - - return forwardRef((props, ref) => ( - - )); - }; + };