Scroll to the top of the page when navigating between template form steps

Signed-off-by: Stephen Glass <stephen@stephen.glass>
This commit is contained in:
Stephen Glass
2025-07-06 00:24:27 -04:00
parent 72f52b6ff9
commit 94c11a5d7f
2 changed files with 13 additions and 0 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/plugin-scaffolder-react': patch
---
Scroll to the top of the page when navigating between steps in template forms.
@@ -37,6 +37,7 @@ import { merge } from 'lodash';
import {
ComponentType,
useCallback,
useEffect,
useMemo,
useState,
type ReactNode,
@@ -218,6 +219,13 @@ export const Stepper = (stepperProps: StepperProps) => {
[validation, analytics],
);
useEffect(() => {
const main = document.querySelector('main');
if (main) {
main.scrollTo({ top: 0, behavior: 'auto' });
}
}, [activeStep]);
const mergedUiSchema = merge({}, propUiSchema, currentStep?.uiSchema);
const [isCreating, setIsCreating] = useState(false);