rstudio / rstudio/bslib

`nav_spacer()` should support a `value` parameter for it to be compatible with `nav_insert()`/`nav_remove()`

Open
#1,106 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
SCSS
Stars
569
Forks
72
Avg merge
1d 2h
Merged PRs (30d)
5

Description

I have a navset_tab() that I programmatically want to generate and regenerate based on server logic. While I am able to set the nav_panel()s perfectly using nav_insert(), I am having trouble with the following layout.

  • Main
  • Menu1
  • Menu2
  • Spacer
  • Menu3
  • Menu4

Now, that Spacer in between gets rendered perfectly on the first go. But then, when I need to regenerate the menu, I cannot remove it using nav_remove() since that needs a value to be passed in the target.

Setting a value on the nav_spacer() gives me an unused argument warning.

I have also tried something as follows, with different variations:

nav_spacer() |>
    tagAppendAttributes(value = "spacer")

nav_spacer() |>
    tagAppendAttributes(`data-value` = "spacer")

nav_spacer() |>
    tagAppendAttributes(`data-value` = "spacer", class = "nav-link")

It would be nice to give the spacer a value and have it behave like the other nav_panel()s to structure more creative menus (some options on the left, others on the right) and then programmatically change them as the user wants and interacts with the app.

From what I can see, the only thing that limits it is the behaviour. Instead of being a proper li item, it is a div, and it does not have a data-value.

This would be useful to have.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with nav_spacer(), nav_insert(), and nav_remove(), then inspect how tagAppendAttributes() affects the generated markup. Done means a spacer accepts a value and can be targeted by nav_remove() while preserving the intended menu layout.

Written by the indexing model from the issue text.

Assessment

Tech stack
r
Domain
frontend
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.