Skip to content

Commit

Permalink
Global styles revisions: ensure redirect runs once for back button (#…
Browse files Browse the repository at this point in the history
…51316)

* Removing location?.path from the dependency to avoid infinite loop and to ensure the internal functions are run once, and as intendted

* Add disable lint rule
  • Loading branch information
ramonjd committed Jun 8, 2023
1 parent 912dfe0 commit 3cef94b
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packages/edit-site/src/components/global-styles/ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,11 @@ function GlobalStylesEditorCanvasContainerLink() {
// redirect from the revisions screen to the root global styles screen.
goTo( '/' );
}
}, [ editorCanvasContainerView, location?.path, goTo ] );
// location?.path is not a dependency because we don't want to track it.
// Doing so will cause an infinite loop. We could abstract logic to avoid
// having to disable the check later.
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [ editorCanvasContainerView, goTo ] );
}

function GlobalStylesUI() {
Expand Down

1 comment on commit 3cef94b

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flaky tests detected in 3cef94b.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/5207986138
📝 Reported issues:

Please sign in to comment.