Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Navigator: fix isInitial logic #65527

Open
wants to merge 2 commits into
base: trunk
Choose a base branch
from
Open

Navigator: fix isInitial logic #65527

wants to merge 2 commits into from

Conversation

ciampo
Copy link
Contributor

@ciampo ciampo commented Sep 20, 2024

What?

Discovered while working on #65523

Set the isInitial flag to false in the internal Navigator reducer only when effectively navigating to a new screen.

Why?

Previously, the isInitial flag was set to false on every navigation, even the ones that were not leading to effectively navigating to a new screen. This was causing unwanted side effects, like the one flagged in #65523

How?

The isInitial flag is set to false only when navigating to a new location.

Testing Instructions

In Storybook:

  • Apply the following diff
diff --git a/packages/components/src/navigator/stories/index.story.tsx b/packages/components/src/navigator/stories/index.story.tsx
index 30b9c71a36..8d4881a563 100644
--- a/packages/components/src/navigator/stories/index.story.tsx
+++ b/packages/components/src/navigator/stories/index.story.tsx
@@ -64,6 +64,10 @@ export const Default: StoryObj< typeof NavigatorProvider > = {
 					<h2>This is the home screen.</h2>
 
 					<VStack alignment="left">
+						<NavigatorButton variant="primary" path="/">
+							Go to home screen.
+						</NavigatorButton>
+
 						<NavigatorButton variant="primary" path="/child">
 							Go to child screen.
 						</NavigatorButton>
  • Load the default Storybook example for Navigator
  • Click on the "Go to home screen" button
  • Make sure the screen doesn't animate

In the editor:

  • Open site editor
  • Open the global styles sidebar
  • Make sure the initial screen doesn't animate

Screenshots or screencast

Before (trunk) After (this PR)
Kapture.2024-09-20.at.14.24.56.mp4
Kapture.2024-09-20.at.14.26.11.mp4

@ciampo ciampo self-assigned this Sep 20, 2024
@ciampo ciampo requested a review from a team September 20, 2024 12:53
@ciampo ciampo added [Type] Bug An existing feature does not function as intended [Package] Components /packages/components Backport to WP 6.7 Beta/RC Pull request that needs to be backported to the WordPress major release that's currently in beta labels Sep 20, 2024
@ciampo ciampo marked this pull request as ready for review September 20, 2024 12:55
Copy link

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: ciampo <mciampini@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Backport to WP 6.7 Beta/RC Pull request that needs to be backported to the WordPress major release that's currently in beta [Package] Components /packages/components [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant