9

Closed

Breadcrumb renders menu when SelectedPath == null

description

Repo:
  1. Create some pages and include them on the main menu.
  2. Add the MenuWidget to the Default layer and check the display as breadcrumb option
  3. Create a new page and do not add it to the navigation menu
  4. View the new page
Outcome - The full menu is shown where the breadcrumb should be.
Expected - Depending on selected options, home page and current page link if selected

The code is in MenuWidgetPartDriver.Display().

if (part.Breadcrumb && selectedPath != null) {
menuItems = selectedPath;
Change to...
if (part.Breadcrumb) {
menuItems = selectedPath ?? Enumerable.Empty<MenuItem>();
Closed May 20, 2013 at 9:02 PM by sebastienros
Has been fixed by another changeset in the meantime.

comments

edikaufmann wrote Nov 19, 2012 at 4:30 PM

above (quick) fix ....
... solves part of the issue BUT shows on the Breadcrumb now the 'HOME' page which is not the 'correct' page.

jao28 wrote Nov 21, 2012 at 7:13 PM

This is the fix that seems to solve all the issues:

// ADDED BY EMS - start
if (part.Breadcrumb) {
if (selectedPath == null) {
    return null;
}
//if (part.Breadcrumb && selectedPath != null) {
menuItems = selectedPath;
// ADDED BY EMS - end
This gets you into the part.Breadcrumb area but then checks the selected path. If it is null, it returns null. This way no breadcrumb is rendered when there is no selected path.

najimoh wrote Jun 25, 2013 at 10:15 AM

Thanks for this post, I have manually do that change and return null in case of selected path is null as "jao28" advised above... that will hide the breadcrumbs menu as expected, but the issue here is there are some HTML still rendered.
<article class="widget-before-main widget-menu-widget widget">
    
</article>
is there any way to remove that HTML also?

jao28 wrote Jun 26, 2013 at 6:38 PM

Hi najimoh, the only way to remove that would be to check if the breadcrumb is empty in the widget.wrapper (and this is not an easy thing and would cause everything to slow down as you are now pre-checking to see if the breadcrumb exists prior to actually rendering the breadcrumb). Two really (I feel better) solutions are:
  • Set up your CSS to have the widget class not have a minimum height (think it does by default and this is why it occupies space) - the html will be there but at least the user won't experience it
  • Create a javascript function (call it in your widget wrapper) that checks to see if the current widget is empty (think you can use innerhtml() as the check) and, if empty, either hides or removes the full element form the DOM
Hope one of these ideas will work for you.