Skip to content

Remove menu_separator before the first navbar item#3001

Open
DanChaltiel wants to merge 3 commits into
r-lib:mainfrom
DanChaltiel:patch-1
Open

Remove menu_separator before the first navbar item#3001
DanChaltiel wants to merge 3 commits into
r-lib:mainfrom
DanChaltiel:patch-1

Conversation

@DanChaltiel

Copy link
Copy Markdown

Hi,

This is a very minor PR to fix a very minor bug.

When the "Articles" navbar menu has sections, a separator is added before the section.

However, for the first section, this doesn't look very nice, as you can see for example on https://roxygen2.r-lib.org/:

image

The PR simply checks that the index is not 1.

Since the second argument of imap() was named index I used it, but maybe purrr::map2(navbar, seq_along(navbar), ...) would be more robust, as this might break in the case where navbar has names. I'm not familiar enough with the API to know if this can happen.

@maelle maelle left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Merci @DanChaltiel! I agree it's ugly as it is now. 💅

Maybe there should be a code comment or an explaining variable (whose value would be index != 1)

I don't understand what you mean by the navbar having names?

Comment thread R/navbar.R Outdated
Co-authored-by: Maëlle Salmon <maelle.salmon@yahoo.se>
@DanChaltiel

DanChaltiel commented Jul 8, 2026

Copy link
Copy Markdown
Author

@maelle An explaining variable is a good idea, I'm on it!

I don't understand what you mean by the navbar having names?

IIUC, imap(navbar) loops over navbar and names(navbar), and defaults to the index when navbar is unnamed. If it is possible that navbar has names at that point, index would be a character and not a numeric, and my test index != 1 would fail.

The alternative with map2() is explicit on using the index and not the names.

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