Force all pages back to the top, rather than just a few of them.

This commit is contained in:
danfunk 2023-05-17 11:58:17 -04:00
parent 2737052c84
commit 2a5d2e545c
4 changed files with 15 additions and 2 deletions

View File

@ -15,6 +15,8 @@ import { AbilityContext } from './contexts/Can';
import UserService from './services/UserService'; import UserService from './services/UserService';
import ErrorDisplay from './components/ErrorDisplay'; import ErrorDisplay from './components/ErrorDisplay';
import APIErrorProvider from './contexts/APIErrorContext'; import APIErrorProvider from './contexts/APIErrorContext';
import ScrollToTop from "./components/ScrollToTop";
import React from "react";
export default function App() { export default function App() {
if (!UserService.isLoggedIn()) { if (!UserService.isLoggedIn()) {
@ -32,6 +34,7 @@ export default function App() {
<BrowserRouter> <BrowserRouter>
<NavigationBar /> <NavigationBar />
<Content> <Content>
<ScrollToTop />
<ErrorDisplay /> <ErrorDisplay />
<ErrorBoundary> <ErrorBoundary>
<Routes> <Routes>

View File

@ -109,7 +109,6 @@ export default function ErrorDisplay() {
if (errorObject) { if (errorObject) {
const title = 'Error:'; const title = 'Error:';
window.scrollTo(0, 0); // Scroll back to the top of the page
errorTag = ( errorTag = (
<Notification title={title} onClose={() => removeError()} type="error"> <Notification title={title} onClose={() => removeError()} type="error">

View File

@ -0,0 +1,12 @@
import { useEffect } from "react";
import { useLocation } from "react-router-dom";
export default function ScrollToTop() {
const { pathname } = useLocation();
useEffect(() => {
window.scrollTo(0, 0);
}, [pathname]);
return null;
}

View File

@ -112,7 +112,6 @@ export default function TaskShow() {
if (!result.can_complete) { if (!result.can_complete) {
navigateToInterstitial(result); navigateToInterstitial(result);
} }
window.scrollTo(0, 0); // Scroll back to the top of the page
/* Disable call to load previous tasks -- do not display menu. /* Disable call to load previous tasks -- do not display menu.
const url = `/v1.0/process-instances/for-me/${modifyProcessIdentifierForPathParam( const url = `/v1.0/process-instances/for-me/${modifyProcessIdentifierForPathParam(