@@ -119,6 +119,20 @@ export default function FullMapView({
119119 const isGtfsFeed = feed ?. data_type === 'gtfs' ;
120120 const hasError = ! isGtfsFeed || feed == null || boundingBox == null ;
121121
122+ const handleExitMap = ( ) : void => {
123+ if ( window . history . length > 1 ) {
124+ router . back ( ) ;
125+ return ;
126+ }
127+
128+ if ( feedId != null ) {
129+ router . replace ( `/feeds/${ feed ?. data_type ?? 'gtfs' } /${ feedId } ` ) ;
130+ return ;
131+ }
132+
133+ router . replace ( '/feeds' ) ;
134+ } ;
135+
122136 const errorDetails = useMemo ( ( ) => {
123137 const messages : string [ ] = [ ] ;
124138 if ( feed == null ) {
@@ -251,13 +265,7 @@ export default function FullMapView({
251265 startIcon = { < ChevronLeft /> }
252266 color = { 'inherit' }
253267 sx = { { pl : 0 , display : { xs : 'none' , md : 'inline-flex' } } }
254- onClick = { ( ) => {
255- if ( ! hasError && feedId != null ) {
256- router . push ( `/feeds/gtfs/${ feedId } ` ) ;
257- } else {
258- router . push ( '/' ) ;
259- }
260- } }
268+ onClick = { handleExitMap }
261269 >
262270 { tCommon ( 'back' ) }
263271 </ Button >
@@ -387,13 +395,7 @@ export default function FullMapView({
387395 size = 'small'
388396 aria-label = { t ( 'fullMapView.aria.close' ) }
389397 sx = { { position : 'absolute' , top : 10 , right : 10 , zIndex : 1000 } }
390- onClick = { ( ) => {
391- if ( ! hasError && feedId != null ) {
392- router . push ( `/feeds/${ feed ?. data_type } /${ feedId } ` ) ;
393- } else {
394- router . push ( '/' ) ;
395- }
396- } }
398+ onClick = { handleExitMap }
397399 >
398400 < CloseIcon />
399401 </ Fab >
0 commit comments