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

[4.x] Add helper arg for addons to easily remove child item in core nav #8883

Merged
merged 2 commits into from
Nov 1, 2023

Conversation

jesseleite
Copy link
Member

@jesseleite jesseleite commented Oct 25, 2023

This PR adds ability for an addon to remove specific core nav item children more easily. For example, in our Shopify rad pack addon, @ryanmitchell is wanting to remove the Products collection item from Collections, because that item is being listed as a child of the Shopify nav item instead.

Before

Nav::extend(function ($nav) {
    $collectionsNav = $nav->content('Collections');

    $children = $collectionsNav
        ->resolveChildren()
        ->children()
        ->reject(function ($item) {
            if (in_array($item->display(), ['Products', 'Variants'])) {
                return true;
            }
        });

    $collectionsNav->children($children);
});

After

Nav::extend(function ($nav) {
    $nav->remove('Content', 'Collections', 'Products');
    $nav->remove('Content', 'Collections', 'Variants');
});

Todo

@jesseleite jesseleite changed the title Add helper arg for addons to easily remove child item in core nav [4.x] Add helper arg for addons to easily remove child item in core nav Oct 25, 2023
@jesseleite jesseleite marked this pull request as ready for review October 31, 2023 20:45
@jesseleite jesseleite requested a review from jasonvarga October 31, 2023 20:53
@jasonvarga
Copy link
Member

Should min version requirement be mentioned in docs

Nope

@jasonvarga jasonvarga merged commit 366ff26 into 4.x Nov 1, 2023
37 of 38 checks passed
@jasonvarga jasonvarga deleted the features/add-arg-to-easily-remove-child-cp-nav-item branch November 1, 2023 14:59
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