File tree Expand file tree Collapse file tree 2 files changed +14
-8
lines changed Expand file tree Collapse file tree 2 files changed +14
-8
lines changed Original file line number Diff line number Diff line change @@ -505,14 +505,11 @@ function App() {
505
505
hidden = { leftPanel !== "gallery" }
506
506
galleryItems = { galleryItems }
507
507
loadDemo = { ( item , switchToCode ) => {
508
- // Load the gallery item every time it's clicked
509
- loadGalleryItem ( item . id ) ;
510
-
511
508
const searchParams = new URLSearchParams ( window . location . search ) ;
512
- if (
513
- ! searchParams . has ( "id" ) ||
514
- ( searchParams . has ( "id" ) && searchParams . get ( "id" ) !== item . id )
515
- ) {
509
+ const isAlreadyActive =
510
+ searchParams . has ( "id" ) && searchParams . get ( "id" ) === item . id ;
511
+
512
+ if ( ! isAlreadyActive ) {
516
513
// only push state if it's not the current url to prevent duplicated in history
517
514
window . history . pushState (
518
515
{ } ,
@@ -522,7 +519,13 @@ function App() {
522
519
}
523
520
524
521
if ( switchToCode ) {
522
+ if ( ! isAlreadyActive ) {
523
+ loadGalleryItem ( item . id ) ;
524
+ }
525
525
setLeftPanel ( "editor" ) ;
526
+ } else {
527
+ // Load the gallery item every time it's clicked ro act as a "rerun" button
528
+ loadGalleryItem ( item . id ) ;
526
529
}
527
530
} }
528
531
/>
Original file line number Diff line number Diff line change @@ -206,8 +206,11 @@ export function GalleryCard({
206
206
< IconButton
207
207
icon = { script }
208
208
label = "Open code"
209
- onClick = { ( ) => {
209
+ onClick = { ( e ) => {
210
+ e . preventDefault ( ) ;
211
+ e . stopPropagation ( ) ;
210
212
loadDemo ( item , true ) ;
213
+ return false ;
211
214
} }
212
215
className = "open-code-btn"
213
216
/>
You can’t perform that action at this time.
0 commit comments