timelyportfolio / listviewer

R htmlwidget to view lists
Other
178 stars 25 forks source link

Column sizing issue with pkgdown and listviewer in view mode #37

Open kscrawfo opened 4 years ago

kscrawfo commented 4 years ago

Hi @timelyportfolio,

I don't think this is specific to your package...but I think it might be related to htmlwidgets and you might have some ideas? I would really appreciate any thoughts - also feel free to delete this issue if its too off topic... Thanks!

I am working on an R package and using pkgdown to build the documentation. I have a multi-level list that I'd like to view and am using the listviewer package with listviewer::jsonedit to display the list. In view mode (also form mode), the list appears to have some sort of sizing issue - the width of the list dynamically resizes, but is not wide enough to display the contents of the list appropriately. This appears to only be an issue when used in view mode with pkgdown (knitr renders fine in the markdown preview, it displays fine in the RStudio viewer fine, no issue with tree or other modes besides view and form). I have not modified any of the pkgdown defaults. I tried inspecting the HTML, but couldn't figure out what was controlling the column widths...

Given the above, I think there may be something going on specifically with pkgdown or htmlwidgets?

Any ideas on why this might be happening?

reprex:

    ---
    title: "test_vignette"
    output: rmarkdown::html_vignette
    vignette: >
      %\VignetteIndexEntry{test_vignette}
      %\VignetteEngine{knitr::rmarkdown}
      %\VignetteEncoding{UTF-8}
    ---

    ```{r out.width = 800}

    test_list = list(
        a = list(
          a1 = 'a1 text',
          a2 = list(
            a2a = 'a2a text',
            a2b = 'a2b text',
            a2c = list(
              a2c1 = 'a2c1 text',
              a2c2 = 'a2c2 text'
              )
          )
        ),
        b = list(
          b1 = 'b1 text',
          b2 = list(
            b2a = 'b2a text',
            b2b = 'b2b text',
            b2c = list(
              b2c1 = 'b2c1 text',
              b2c2 = 'b2c2 text'
              )
          )
        )
    )

    listviewer::jsonedit(test_list,
                         mode = 'view')


Pkgdown vignette (list collapsed) - not good:
![image](https://user-images.githubusercontent.com/59714899/91070270-6141d100-e5eb-11ea-87f4-0d6595844455.png)

Pkgdown vignette (list expanded) - not good:
![image](https://user-images.githubusercontent.com/59714899/91070293-6737b200-e5eb-11ea-8c0f-1cffd8a08b79.png)

RStudio viewer (similar for knitr) - good:
![image](https://user-images.githubusercontent.com/59714899/91070301-6a32a280-e5eb-11ea-8499-d3c9d835ce2d.png)
kscrawfo commented 4 years ago

After spending some more time on this, I've found that I can get the view mode to somewhat work...if I indent the entire block of r code 4 spaces. I say somewhat because the listviewer window now appears 'inside' a code block...but it has a scrollbar inside the listviewer window (regardless of how wide I set the output).

indented 4 spaces

    ```{r}
    listviewer::jsonedit(test_list,
                         mode = 'view')

![image](https://user-images.githubusercontent.com/59714899/91075795-73c00880-e5f3-11ea-96ba-ced74deee98e.png)

not indented 4 spaces

listviewer::jsonedit(test_list,
                     mode = 'view')

image