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 Screen: warn if path doesn't follow a URL-like scheme #65231

Merged
merged 3 commits into from
Sep 11, 2024

Conversation

ciampo
Copy link
Contributor

@ciampo ciampo commented Sep 11, 2024

What?

Add a runtime check in NavigatorScreen to warn consumers when the path prop doesn't follow the expected format

Why?

When the expected format is not used, Navigator doesn't behave as expected (see, for example, #65109). A runtime check is one more way that we can help consumers of Navigator to use the component as expected.

How?

If the path doesn't start with /, output a warning to console.

Testing Instructions

In dev mode, in the editor try changing the path of a NavigatorScreen component and remove the leading / — a warning should be printed to console.

The new unit test should pass.

Copy link

github-actions bot commented Sep 11, 2024

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>
Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>
Co-authored-by: ramonjd <ramonopoly@git.wordpress.org>

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

@ciampo ciampo self-assigned this Sep 11, 2024
@ciampo ciampo requested a review from ramonjd September 11, 2024 08:28
@ciampo ciampo added [Type] Enhancement A suggestion for improvement. [Package] Components /packages/components labels Sep 11, 2024
Copy link
Member

@Mamaduka Mamaduka left a comment

Choose a reason for hiding this comment

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

Thank you, @ciampo!

Copy link
Member

@ramonjd ramonjd left a comment

Choose a reason for hiding this comment

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

I have been warned! LGTM

Screenshot 2024-09-11 at 6 33 04 PM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Package] Components /packages/components [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants