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

Patterns Browse Screen: Fix back button when switching between categories #52964

Merged
merged 1 commit into from
Jul 27, 2023
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 @@ -12,19 +12,11 @@ export default function CategoryItem( {
label,
type,
} ) {
const linkInfo = useLink(
{
path: '/patterns',
categoryType: type,
categoryId: id,
},
{
// Keep a record of where we came from in state so we can
// use the browser's back button to go back to Patterns.
// See the implementation of the back button in patterns-list.
backPath: '/patterns',
Copy link
Member

Choose a reason for hiding this comment

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

Unfortunately, this makes mobile back button push to the history stack instead of backing when available.

I believe this issue was introduced in #52910 but I haven't looked deep into the issue to provide any valuable insight 😅 . (c.c. @noisysocks)

Copy link
Member

Choose a reason for hiding this comment

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

I tested trunk and looks like it's working as expected. The back button goes "up" not "back" and so therefore creates a new entry in the browser's history. That's how the other screens work too e.g. if you go to Pages → About, click the back button, and then go back with your browser, you end up at About.

Copy link
Member

Choose a reason for hiding this comment

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

What I mean is I expect the back button to behave exactly like the browsers' back button whenever possible. Something like a smart back button.

I don't think this has that high of a priority though 🙂 . Perhaps we could revisit this once we have a more robust routing architecture.

}
);
const linkInfo = useLink( {
path: '/patterns',
categoryType: type,
categoryId: id,
} );

if ( ! count ) {
return;
Expand Down