Skip to content

Fixes reporter bug where buttons would appear in other tabs when reporter is NULL (alternative) - #1737

Closed
averissimo wants to merge 4 commits into
mainfrom
1727-fix_reporter
Closed

averissimo wants to merge 4 commits into
mainfrom
1727-fix_reporter

Conversation

@averissimo

@averissimo averissimo commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor

Pull Request

Fixes #1727

Alternative approach: #1737

Changes description

  • Add reporter argument to ui_teal* functions and propagate it down
  • Menu item and "Add to Report" button is not rendered instead of being removed by JS

Alternative

Part of the reason why we didn't do this before was to allow srv_teal and ui_teal to work with reporter by only supplying the server function and allow it to manage the UI

The drawback is that there is a visual glitch where the buttons are showed momentarily, before removeUi is executed (however that was something already established)

@averissimo
averissimo requested a lite review from Copilot September 15, 2026 11:32

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Unresolved reporter UI behavior and incomplete test coverage remain.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

Fixes reporter controls appearing in other tabs when reporter is NULL.

Changes:

  • Propagates reporter through UI modules.
  • Conditionally renders reporter menus and buttons.
  • Updates tests, documentation, and NEWS.
File summaries
File Summary Review notes
tests/testthat/test-module_teal.R Adds reporter UI coverage. Moderate issue (3 votes): test selector does not match the rendered element.
R/module_teal.R Controls reporter menu rendering. Moderate issue (1 vote): separate UI/server calls can leave controls visible without handlers.
R/module_nested_tabs.R Propagates reporter state and conditionally renders buttons. —
R/init.R Passes reporter into the UI. —
NEWS.md Documents the bug fix. —
man/module_teal.Rd Documents the UI argument. —
man/module_teal_module.Rd Updates nested module documentation. —
Review details

Files not reviewed (2)

  • man/module_teal.Rd: Generated file
  • man/module_teal_module.Rd: Generated file

Suppressed comments (1)

R/module_teal.R:48

  • ui_teal() and srv_teal() are separate module calls, so existing callers can use the default UI here while passing reporter = NULL only to srv_teal(). Before this change the server removed the already-rendered menu and wrappers for that supported combination; after removing that fallback, those controls remain visible but have no handlers. Preserve a fallback removal or make the UI/server reporter contract explicit and enforce it.
ui_teal <- function(id, modules, reporter = teal.reporter::Reporter$new()) {
  • Files reviewed: 5/7 changed files
  • Comments generated: 1
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread tests/testthat/test-module_teal.R
@averissimo averissimo changed the title Fixes reporter bug where buttons would appear in other tabs when reporter is NULL Fixes reporter bug where buttons would appear in other tabs when reporter is NULL (alternative) Sep 15, 2026

@osenan osenan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This PR is also simple, not as minimal as its alternative #1738 but stays consistent. I think we need to update the status of withr in the DESCRIPTION and slightly modify the vignette of the teal as a shiny module.
Corresponds more to the product decision to see which solution is accepted. The complexity of this PR is small, IMO opinion the improvement is not very different, but we can accept both solutions.

Comment thread R/module_teal.R
teal.reporter::reset_report_button_ui(ns("reset_reports"), label = "Reset Report")
}
if (!is.null(reporter)) {
withr::with_options(reporter_opts, { # for backwards compatibility of the report_previewer_module$server_args

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I am surprised withr package is in suggest, it shuold be on imports as it is necessary for the reporter funcionality.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good point, we can use rlang::with_options which should result in the same outcome

Comment thread R/module_teal.R

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Maybe we can make small update in vignette teal-as-shiny-module to show the usage of reporter argument for function ui_teal

@osenan osenan self-assigned this Sep 16, 2026
averissimo added a commit that referenced this pull request Sep 17, 2026
…rter is `NULL` (#1738)

# Pull Request

Fixes #1727

Alternative approach:
#1737

### Changes description

- Remove all elements of "Add to report" in modules, instead of just one

---------

Signed-off-by: André Veríssimo <211358+averissimo@users.noreply.github.com>
Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@averissimo averissimo closed this Sep 17, 2026
@github-actions github-actions Bot locked and limited conversation to collaborators Sep 17, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: init(reporter = NULL) only removed the Add to Report button in the first module

3 participants