@@ -47,6 +47,7 @@ import React, {
4747import { createPortal } from 'react-dom' ;
4848import { useHotkeys } from 'react-hotkeys-hook' ;
4949import { Trans , useTranslation } from 'react-i18next' ;
50+ import { useLocation } from 'react-router-dom' ;
5051import { useTypedSelector } from '../../redux/hooks' ;
5152import store from '../../redux/stores/store' ;
5253import { activitySlice } from './activitySlice' ;
@@ -946,6 +947,28 @@ export const ActivitiesRenderer = React.memo(function ActivitiesRenderer() {
946947 const history = useTypedSelector ( state => state . activity . history ) as string [ ] ;
947948 const lastElement = history . at ( - 1 ) ;
948949 const [ isOverview , setIsOverview ] = useState ( false ) ;
950+ const location = useLocation ( ) ;
951+ const locationRef = useRef ( location . pathname ) ;
952+
953+ // Minimize activities that block the main content on route change.
954+ // Activities in 'split-right' location are kept visible since they
955+ // allow the user to see most of the main content.
956+ useEffect ( ( ) => {
957+ activities . forEach ( activity => {
958+ // If we were triggered just because of the activities changing but the
959+ // location hasn't changed, we have nothing to do.
960+ if ( locationRef . current === location . pathname ) {
961+ return ;
962+ }
963+
964+ if ( activity . location !== 'split-right' && ! activity . minimized ) {
965+ Activity . update ( activity . id , { minimized : true } ) ;
966+ }
967+ } ) ;
968+
969+ locationRef . current = location . pathname ;
970+ } , [ location . pathname , activities ] ) ;
971+
949972 useEffect ( ( ) => {
950973 if ( activities . length === 0 && isOverview ) {
951974 setIsOverview ( false ) ;
0 commit comments