Skip to content

Dashboard: bslib::value_box() ignores #| expandable: false and shows Expand button #14719

Description

@mcanouil

I have:

  • searched the issue tracker for similar issues
  • installed the latest version of Quarto CLI
  • formatted my issue following the Bug Reports guide

Bug description

In a format: dashboard document, a cell that outputs a bslib component such as bslib::value_box() shows an "Expand" (full-screen) button in the bottom-right corner even when the cell sets #| expandable: false. A Quarto-native value box, or a plain plot(), correctly honours the option and shows no button.

Reported in discussion #14714. Root cause traced below.

Steps to reproduce

---
format: dashboard
---

## Column

```{r}
#| expandable: false
bslib::value_box(title = "x", value = 1, theme = "primary")
```

Actual behavior

The value box renders with an "Expand" button; #| expandable: false has no effect.

Root cause (against v1.9.38, SHA 6ebb5db80eb542ac76189c3d7c33ae6f654b93d2):

  1. When a cell outputs raw bslib- HTML, dashboard.lua captures it into bslibRawOutputs and re-emits it "unharmed". The cell's card options are read via readOptions(el)/makeCard(...) but applied only to the remaining non-bslib content, so #| expandable: false never reaches the value box and no data-expandable attribute is emitted on it.

    • if #bslibRawOutputs > 0 then
      -- If bslib outputs were detected, we need to elevate those rawblocks and
      -- just allow them to pass through the system unharmed along side
      -- the cell and any of its other output
      local result = pandoc.Blocks(bslibRawOutputs)
      if el ~= nil and #el.content > 0 then
      local options, userClasses = dashboard.card.readOptions(el)
      local card = dashboard.card.makeCard(el.content, userClasses, options)
      if card ~= nil then
      result:insert(card)
      end
      end
      return result
  2. In HTML post-processing, processCards handles every .card, including the bslib value box. With no data-expandable attribute present, defaultValue decides: it suppresses the button only for elements with Quarto's own class kValueboxClass ("valuebox") or a flow layout. A bslib value box uses bslib-value-box, so the check misses and the fallback returns dashboardMeta.expandable, which defaults to true, injecting Quarto's own Expand button (kExpandBtnHtml).

    • attr: kAttrExpandable,
      handle: (el: Element, attrValue: string) => {
      if (attrValue !== "false") {
      const shellEl = doc.createElement("DIV");
      shellEl.innerHTML = kExpandBtnHtml;
      for (const childEl of shellEl.children) {
      el.appendChild(childEl);
      }
      el.setAttribute(kAttrFullScreen, "false");
      }
      },
      defaultValue: (el: Element) => {
      if (el.classList.contains(kValueboxClass) || hasFlowLayout(el)) {
      return "false";
      } else {
      return dashboardMeta.expandable ? "true" : "false";
      }
      },
      },
      {
    • export const kValueboxClass = "valuebox";

Because the button is Quarto's, passing full_screen = FALSE to bslib::value_box() does not remove it.

Expected behavior

#| expandable: false on a cell that outputs a bslib::value_box() (or any bslib card) should suppress the Expand button, matching the behaviour of Quarto-native value boxes.

Your environment

  • OS: Ubuntu 24.04
  • bslib: 0.11.0.9000

(Environment as reported in discussion #14714.)

Quarto check output

Quarto 1.9.38 (as reported in discussion #14714). Root cause verified against source at tag v1.9.38 and reproduces on main. Full quarto check output was not provided by the original reporter.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions