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

BUG Don't double up the breadcrumb on list views #2976

Conversation

maxime-rainville
Copy link
Contributor

@maxime-rainville maxime-rainville commented Jul 21, 2024

Description

This PR refactors how the CMS breadcrumb is generated.

It fix a bug causing crumbs to be duplicated on the list view.

It also ensures the "Pages" top crumb is always shown on the list view.

It adds missing unit tests.

Manual testing steps

  • Validate that the breadcrumb is still shown correctly:
    • on the page edit form
    • on the list view when access directly
    • on the list view when access via a PJAX
    • on the page search results.
  • Validate that crumbs link where you expect them to link.

Issues

Pull request checklist

  • The target branch is correct
  • All commits are relevant to the purpose of the PR (e.g. no debug statements, unrelated refactoring, or arbitrary linting)
  • The commit messages follow our commit message guidelines
  • The PR follows our contribution guidelines
  • Code changes follow our coding conventions
  • This change is covered with tests (or tests aren't necessary for this change)
  • Any relevant User Help/Developer documentation is updated; for impactful changes, information is added to the changelog for the intended release
  • CI is green

Copy link
Member

@GuySartorelli GuySartorelli left a comment

Choose a reason for hiding this comment

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

While I appreciate the initiative with all of the refactoring, it made it a lot more time consuming to review since I needed to compare the original code with the new code and parse out the changes and see what moved where, etc etc.

In the future can you please try to keep refactoring separate from fixing the bug? At the very least having separate commit (one dedicated to just what's necessary to fix the bug, and a separate one for the refactoring) would make it a lot easier to keep track of.

code/Controllers/CMSMain.php Outdated Show resolved Hide resolved
code/Controllers/CMSPagesController.php Show resolved Hide resolved
code/Controllers/CMSMain.php Show resolved Hide resolved
code/Controllers/CMSMain.php Show resolved Hide resolved
Comment on lines +1082 to +1086
/**
* Push the provided an extra breadcrumb crumb at the end of the provided List
*/
private function pushCrumb(ArrayList $items, string $title, string|false $link): void
{
$items->push(ArrayData::create([
'Title' => $title,
'Link' => $link
]));
}
Copy link
Member

@GuySartorelli GuySartorelli Jul 22, 2024

Choose a reason for hiding this comment

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

This extra method seems kinda unnecessary but not worth the ping pong to remove it, since it's private anyway.

code/Controllers/CMSMain.php Outdated Show resolved Hide resolved
code/Controllers/CMSMain.php Show resolved Hide resolved
@GuySartorelli
Copy link
Member

Please also change the commit prefix to FIX as per the commit message guidelines linked in the PR description.

@maxime-rainville maxime-rainville force-pushed the pulls/5.2/list-view-breadcrumb branch from b1a8601 to 9072345 Compare July 24, 2024 09:32
Copy link
Contributor Author

@maxime-rainville maxime-rainville left a comment

Choose a reason for hiding this comment

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

While I appreciate the initiative with all of the refactoring, it made it a lot more time consuming to review since I needed to compare the original code with the new code and parse out the changes and see what moved where, etc etc.

In the future can you please try to keep refactoring separate from fixing the bug? At the very least having separate commit (one dedicated to just what's necessary to fix the bug, and a separate one for the refactoring) would make it a lot easier to keep track of.

Sorry for the unduly big change. But the more I looked at this thing, the more it seemed like the bugs were fundamentally caused by the bad implementation.

Refactoring the code while replicating the bugs would have probably made this PR even more complex. And I don't think there would have been a way to fix the bugs without addressing the underlying poor implementation.

Please also change the commit prefix to FIX as per the commit message guidelines linked in the PR description.

Done.

Copy link
Member

@GuySartorelli GuySartorelli left a comment

Choose a reason for hiding this comment

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

LGTM, works well locally.

I found a new related bug that when I'm in list view and drill down to a specific page, if I then toggle to "tree view" it'll retain the ?ParentID=9 in the URL and keeps the breadcrumbs there. But I tested that without this PR and it was still happening so it's an existing bug.

@GuySartorelli GuySartorelli merged commit 6218b13 into silverstripe:5.2 Jul 24, 2024
16 checks passed
@maxime-rainville maxime-rainville deleted the pulls/5.2/list-view-breadcrumb branch July 25, 2024 01:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants