@@ -8,6 +8,15 @@ import { FundableContent } from "@site/src/pages/sponsor";
88import styles from "@site/src/components/about/styles.module.css" ;
99import LargeProjectCard from './LargeProjectCard' ;
1010
11+ function backToOverview ( history , scrollY ) {
12+ const category = new URLSearchParams ( window . location . search ) . get ( "category" ) ;
13+ const search = category ? `?category=${ encodeURIComponent ( category ) } ` : "" ;
14+ history . replace ( { pathname : '/sponsor' , search } ) ;
15+ if ( scrollY !== undefined ) {
16+ setTimeout ( ( ) => window . scrollTo ( { top : scrollY , behavior : 'auto' } ) , 0 ) ;
17+ }
18+ }
19+
1120export default function LargeProjectCardPage ( ) {
1221 const location = useLocation ( ) ;
1322 const history = useHistory ( ) ;
@@ -18,26 +27,15 @@ export default function LargeProjectCardPage() {
1827 }
1928 } , [ ] ) ;
2029
21- const handleOverlayClick = ( ) => {
22- const scrollY = location . state ?. scrollY ;
23- setTimeout ( ( ) => {
24- if ( scrollY !== undefined ) {
25- window . scrollTo ( { top : scrollY , behavior : 'auto' } ) ;
26- }
27- } , 0 ) ;
28- history . replace ( '/sponsor' ) ;
30+ const handleOverlayClick = ( e ) => {
31+ if ( window . getSelection ( ) ?. toString ( ) ) return ;
32+ if ( e . target !== e . currentTarget ) return ;
33+ backToOverview ( history , location . state ?. scrollY ) ;
2934 } ;
3035
3136 const handleClose = ( ) => {
32- const scrollY = location . state ?. scrollY ;
3337 if ( location . state ?. fromFundable ) {
34- history . replace ( '/sponsor' ) ;
35-
36- setTimeout ( ( ) => {
37- if ( scrollY !== undefined ) {
38- window . scrollTo ( { top : scrollY , behavior : 'auto' } ) ;
39- }
40- } , 0 ) ;
38+ backToOverview ( history , location . state ?. scrollY ) ;
4139 } else {
4240 history . goBack ( ) ;
4341 }
0 commit comments