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

Feat: option to retain child menu items when visible=False #143

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

benhowes
Copy link

This PR adds the option for child menu items to not be removed from the list when item.visible == False.

Usecase

I am using django-simple-menu both for menu items and for breadcrumb generation. There are several cases where a menu item is not visible to click, but can produce an entry in the breadcrumb trail.

As a work-around (and due to the simplicity of the site structure I am working on at present) I have been able to get away with simply leaving visible=True on all items and not rendering any child items. This will not work forever though.

The change

This change adds a new setting MENU_TRIM_NON_VISIBLE_CHILD_ITEMS which defaults to the existing behaviour of removing all non-visible child items, but, it can be set to False which will then retain these items. As such, this is a non-breaking change for existing users.

The default templates in this repo should work either way because item.visible is always checked, but I can appreciate that some people will have custom templates which do not perform this check.

I've added some tests, but please let me know if there's anything further I can do to help get this merged in.

@benhowes benhowes changed the title Feature/retain non visible children Feat: option to retain child menu items when visible=False Dec 20, 2023
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.

1 participant