From e11111755bede7b5dcfb55905c0455b258ed7f15 Mon Sep 17 00:00:00 2001 From: Kelly Dwan Date: Fri, 7 Jun 2024 14:44:19 -0400 Subject: [PATCH] Track the total history --- .../themes/wporg-themes-2024/src/theme-previewer/view.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/source/wp-content/themes/wporg-themes-2024/src/theme-previewer/view.js b/source/wp-content/themes/wporg-themes-2024/src/theme-previewer/view.js index 20abb4b..35b4999 100644 --- a/source/wp-content/themes/wporg-themes-2024/src/theme-previewer/view.js +++ b/source/wp-content/themes/wporg-themes-2024/src/theme-previewer/view.js @@ -9,7 +9,7 @@ const { state } = store( 'wporg/themes/preview', { const context = getContext(); return context.isLoaded; }, - pages: 1, + initialHistory: window.history.length, }, actions: { onLoad() { @@ -17,9 +17,9 @@ const { state } = store( 'wporg/themes/preview', { context.isLoaded = true; }, goBack( event ) { - if ( window.history.length > state.pages ) { + if ( state.initialHistory > 2 ) { event.preventDefault(); - window.history.go( state.pages * -1 ); + window.history.go( state.initialHistory - window.history.length - 1 ); } }, navigateIframe( event ) { @@ -53,7 +53,6 @@ const { state } = store( 'wporg/themes/preview', { context.url = previewURL; window.history.replaceState( {}, '', permalinkURL ); - state.pages++; } }, },