Bogleheads:Sandbox

Testing nested Navboxes
The following wikitext creates a usable nested Navbox on Wikipedia:Special:ExpandTemplates, but appears to misbehave on our wiki. Minimum useful failing example:

Result:

The child Navbox displays simultaneously in both Desktop and Mobile formats.

Digging around further, it appears that Module:NavboxMobile with  breaks   restrictions placed around it in Navbox.

Test:
 * Before. This should only display in mobile browsers, but breaks the restriction. After.

Result:
 * Before. This should only display in mobile browsers, but breaks the restriction. After.

The problem is that  starts by outputting , and this leading   closes the opening. It then goes on to end with an opening  of its own.

Example:
 * Before. This should only display in mobile browsers, but breaks the restriction. After.

Result:
 * Before. This should only display in mobile browsers, but breaks the restriction. After.

Replacing  with the main   behaves the same way though, so for whatever reason the module is designed to have this behaviour when invoked with. Where this breaks down is where Navbox adds the nombile/onlymobile wrapper. This gets in the way of whatever div this module finds it necessary to close on entry, and then re-open on exit.

Speculation: wrapping both invocations in the template inside their own  might get round the problem. (A design that requires a component to start by closing a div and end by opening a new one is probably not a robust one.)