GT Interactive Mode: opt_interactive Doesn't Display Correctly in Plot Pane or Viewer Pane
Positron Version:
Positron Version: 2024.07.0 (Universal) build 15 Code - OSS Version: 1.90.0 Commit: d8da3ec9581aa7bcb9726babedacff4e3d528503 Date: 2024-07-05T03:51:32.592Z Electron: 29.4.0 Chromium: 122.0.6261.156 Node.js: 20.9.0 V8: 12.2.281.27-electron.0 OS: Darwin x64 22.6.0
Steps to reproduce the issue:
- create r file or qmd file.
- execute the code below:
library(gt)
towny |>
dplyr::select(name, census_div, starts_with("population")) |>
gt() |>
fmt_integer() |>
cols_label_with(fn = function(x) sub("population_", "", x)) |>
cols_width(
name ~ px(200),
census_div ~ px(200)
) |>
tab_header(
title = "Populations of Municipalities",
subtitle = "Census values from 1996 to 2021."
) |>
tab_source_note(source_note = md("Data taken from the `towny` dataset.")) |>
opt_interactive(use_search = TRUE, use_filters = TRUE, use_compact_mode = TRUE)
The result appears in the plot area as a static image, which I believe it shouldn't.
What did you expect to happen?
Since this is an HTML render, I expected it to appear in the viewer pane. The image below is from VSCodium:
Were there any error messages in the output or Developer Tools console?
no.
Other notes:
I opened this issue even though I saw some related to displaying HTML widgets in the viewer pane, but nothing specific to the gt package. though, I found this comment about gt https://github.com/posit-dev/positron/discussions/3686#discussioncomment-9905639 The problem is with the function opt_interactive. When I remove this function, the table displays again in the plot pane.
Thank you
I'm able to reproduce this issue on Mac
I think this is same issue as https://github.com/posit-dev/positron/issues/4057. This widget is getting rendered as HTML in R instead of being packaged up as a structured HTML widget. That means we don't get any metadata about its dependencies (so they don't load), nor its sizing policy (so we don't know where to put it).
Should be resolved with #4151:
Verified Fixed
Positron Version(s) : 2024.07.0-107
OS Version : OSX
Test scenario(s)
library(gt)
towny |>
dplyr::select(name, census_div, starts_with("population")) |>
gt() |>
fmt_integer() |>
cols_label_with(fn = function(x) sub("population_", "", x)) |>
cols_width(
name ~ px(200),
census_div ~ px(200)
) |>
tab_header(
title = "Populations of Municipalities",
subtitle = "Census values from 1996 to 2021."
) |>
tab_source_note(source_note = md("Data taken from the towny dataset.")) |>
opt_interactive(use_search = TRUE, use_filters = TRUE, use_compact_mode = TRUE)
Link(s) to TestRail test cases run or created: N/A
Thanks, it works like a charm now!