Template talk:Navbox

  (Redirected from Module talk:Navbox)
Jump to navigation Jump to search

colspan causes unnecessary wrapping in groupless navboxes with 'width:auto'

In navboxes with no groupN, no image, and with width:auto applied, the default colspan="2" that gets added to each of the rows causes the navbox to adopt the width of the content in the final row/cell, even when this causes content in earlier rows to wrap. See for example Template:Set navigation on Yugipedia. Simply removing the unnecessary colspans is enough to fix this (interestingly, at least in Chrome, it seems that just removing the colspan in the header is enough to fix it). I would take a crack at this myself, but I have no idea how to check for the existence of any groupN without just looping through all the possible names. ディノ千?!☎ Dinoguy1000 21:21, 14 July 2019 (UTC)

I guess the way to check for any groupN parameters would be something like the getArgNums() function in Module:Infobox, actually. ディノ千?!☎ Dinoguy1000 21:30, 14 July 2019 (UTC)
*poke* ディノ千?!☎ Dinoguy1000 18:28, 1 December 2019 (UTC)

Set class for navbox wrapper div

On English Wikisource we have some project-specific concerns that necessitate being able to address the entire generated navbox from CSS and JS. We do this with a custom extra parameter (somewhat awkwardly named |wrapclass=) that allows the template calling _navbox to pass in a custom CSS class that gets applied to the navbox's wrapping div. The code for this custom param is a bit of a pain to keep patching in every time we resync from enwp, and it is functionallity that is both cheap and potentially useful elsewhere, so I figured I'd test the waters for adding this functionality (with a better param name) to the upstream module (i.e. here).

The only code change is to the module like so:

426 		local nav = res:tag('div')
427 			:attr('role', 'navigation')
428 			:addClass('navbox')
429             :addClass(args.wrapclass) -- <== NEW: add class passed in wrapclass param
430 			:cssText(args.bodystyle)
431 			:cssText(args.style)
432 			:css('padding', '3px')
433 			:node(tbl)

I would suggest something like |navbox-class= for the parameter name. Thoughts? --Xover (talk) 10:33, 10 August 2019 (UTC)

This was discussed quite recently. It is also generally necessary for deployment of TemplateStyles.
Feel free to implement this in the module sandbox and then set up tests in the test case pages. I don't know about en.ws, but en.wp has many edge cases. --Izno (talk) 13:47, 10 August 2019 (UTC)
@Izno: done. There are no testcases for the module, only for the wrapper template, and this change only affects the module. The new argument is named navboxclass and can be added to the invocation of _navbox in Module:Authority control to set the given class on the navbox's wrapper div (that's actually the exact use case at enWS that prompted this). @Tom.Reding: Can you sync this over from the sandbox to the live module, or should I throw out a {{TPER}}? --Xover (talk) 15:39, 10 August 2019 (UTC)
Xover, done, although |outerclass= may have been more accurate, this works as well. Frietjes (talk) 17:26, 10 August 2019 (UTC)

Template-protected edit request on 14 August 2019

To improve the performance of the collapsible code, I request to make [1]. This will cause the parser to preload the collapsible code, avoiding an additional resourceloader lazyloading call to be made, which makes pages containing navboxes a little more efficient. —TheDJ (talkcontribs) 12:33, 14 August 2019 (UTC)

@TheDJ: Have you done any testing to indicate that this should have no visible impact? --Izno (talk) 03:10, 15 August 2019 (UTC)
Izno, {{Navbox/testcases}}. It basically just skips the JS transform inside MediaWiki:Common.js that would otherwise happen to collapsible, but by using mw-collapsible, the JS will be predelivered by the MW parser, which makes it faster. —TheDJ (talkcontribs) 07:00, 15 August 2019 (UTC)
@TheDJ: One of the reasons I ask is that the translation in Common.js also handles the states that mw-collapsible did not for a portion of time (autocollapse I think was one?). Does mw-collapsible also handle those now? --Izno (talk) 11:35, 15 August 2019 (UTC)
Izno, yes it does. The mwCollapsibleSetup hook in our Common.js does that for all mw-collapsibles and all collapsibles are already converted to mw-collapsible on the fly right now (this just makes it faster) —TheDJ (talkcontribs) 15:41, 15 August 2019 (UTC)
 Done Izno (talk) 17:49, 18 August 2019 (UTC)

Spacing for ungrouped item after subgroups

Template:Ainur Group1 (Valar) comprises 2 subgroups and then an ungrouped item, Morgoth. There is no space before the entry "Morgoth".

In contrast, Group 2 (Maiar) starts with some ungrouped items, then two subgroups. The ungrouped entries (Eonwe…) have an appropriate space before the first one.

Is this a weakness in the coding for {{Navbox}}, or can Template:Ainur be formatted better, to align the spacing of all ungrouped items? – Fayenatic London 14:59, 24 January 2020 (UTC)

Morgoth (Melkor) is an entry in a valid list with <ul>...</ul> tags, albeit a list with just one item. The list is enclosed in a <div>...</div> with no styling. Eönwë, Sauron and Melian are also list items, but they do not have enclosing <ul>...</ul> tags - instead they have an enclosing <div style="padding:0em 0.25em">...</div> - that 0.25em padding on right and left is what causes the gap. I think that the problem is with {{navbox}}, and may be a WP:VPT matter. --Redrose64 🌹 (talk) 23:39, 24 January 2020 (UTC)
Fixed, I believe. – Jonesey95 (talk) 23:50, 24 January 2020 (UTC)
The article is a derivative under the Creative Commons Attribution-ShareAlike License. A link to the original article can be found here and attribution parties here. By using this site, you agree to the Terms of Use. Gpedia Ⓡ is a registered trademark of the Cyberajah Pty Ltd.