positron icon indicating copy to clipboard operation
positron copied to clipboard

GT Interactive Mode: opt_interactive Doesn't Display Correctly in Plot Pane or Viewer Pane

Open bassamsdata opened this issue 1 year ago • 3 comments

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:

  1. create r file or qmd file.
  2. 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. Screenshot 2024-07-06 at 11 24 15 AM

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: Screenshot 2024-07-06 at 11 28 22 AM

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

bassamsdata avatar Jul 06 '24 15:07 bassamsdata

I'm able to reproduce this issue on Mac

petetronic avatar Jul 07 '24 18:07 petetronic

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).

jmcphers avatar Jul 18 '24 15:07 jmcphers

Should be resolved with #4151:

image

jmcphers avatar Jul 25 '24 22:07 jmcphers

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

testlabauto avatar Jul 29 '24 17:07 testlabauto

Thanks, it works like a charm now!

bassamsdata avatar Jul 29 '24 19:07 bassamsdata