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

Edit Site: Fix sidebar template author navigation #67382

Merged
merged 1 commit into from
Nov 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { useMemo } from '@wordpress/element';
import { __experimentalItemGroup as ItemGroup } from '@wordpress/components';
import { __ } from '@wordpress/i18n';
import { privateApis as routerPrivateApis } from '@wordpress/router';
import { addQueryArgs } from '@wordpress/url';

/**
* Internal dependencies
Expand All @@ -25,7 +26,7 @@ function TemplateDataviewItem( { template, isActive } ) {

return (
<SidebarNavigationItem
to={ `/template?activeView=${ text }` }
to={ addQueryArgs( '/template', { activeView: text } ) }
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't undestand what's the difference between the two codes?

Copy link
Member Author

Choose a reason for hiding this comment

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

Basically, URL encoding.

The version in trunk will navigate to:

/template?activeView=Twenty Twenty-Four

while the version here will navigate to:

/template?activeView=Twenty%20Twenty-Four

and the former seems to break the navigation.

Copy link
Contributor

Choose a reason for hiding this comment

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

makes sense :)

Copy link
Member Author

Choose a reason for hiding this comment

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

Shipping this one, but it might make sense to double-check other instances where we hardcoded the query string instead of using addQueryArgs().

Cases like this are exactly why I was suggesting defaulting to addQueryArgs() FWIW.

icon={ icon }
aria-current={ isActive }
>
Expand Down
Loading