Skip to content

Respect cols_merge() + sub_*() with opt_interactive()#1786

Merged
rich-iannone merged 7 commits intorstudio:masterfrom
olivroy:interactive-merge-1785
Jul 15, 2024
Merged

Respect cols_merge() + sub_*() with opt_interactive()#1786
rich-iannone merged 7 commits intorstudio:masterfrom
olivroy:interactive-merge-1785

Conversation

@olivroy
Copy link
Collaborator

@olivroy olivroy commented Jul 15, 2024

Summary

Basically, this assumes that the first variable is always where the merge happened? Seems so, based on

Basically, the reason why the merged cells didn't show is because extract_cells() was not run on newly created variavbles.

Note that dt_col_merge_get_vars() seems to properly return NULL when no merge happens!

I added substitution since the fix was very similar!

# Html
gt_tbl <- sp500 |>
    dplyr::slice(50:55) |>
    dplyr::select(-volume, -adj_close) |>
    gt::gt() |>
    cols_merge(
        columns = c(open, close),
        pattern = "{1}&mdash;{2}"
    ) |>
    cols_merge(
        columns = c(low, high),
        pattern = "{1}&mdash;{2}"
    ) |>
    cols_label(
        open = "open/close",
        low = "low/high"
    ) 
gt_tbl

image

# Before
gt_tbl |> opt_interactive()

image

# This PR
gt_tbl |> opt_interactive()

image

Related GitHub Issues and PRs

Fixes #1785, Fixes #1759 Fixes #1846

Checklist

@olivroy olivroy requested a review from rich-iannone July 15, 2024 13:34
@olivroy olivroy changed the title Respect cols_merge() with opt_interactive()` Respect cols_merge() with opt_interactive() Jul 15, 2024
@olivroy olivroy changed the title Respect cols_merge() with opt_interactive() Respect cols_merge() + sub_*() with opt_interactive() Jul 15, 2024
Copy link
Member

@rich-iannone rich-iannone left a comment

Choose a reason for hiding this comment

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

LGTM!

@rich-iannone
Copy link
Member

Thank you @olivroy for getting to the bottom of this and resolving with the PR! Will merge this once CI passes.

@rich-iannone rich-iannone merged commit 60dabaf into rstudio:master Jul 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

opt_interactive() breaks web_image() in 0.11 opt_interactive() doesn't respect cols_merge() opt_interactive() doesn't respect substitution.

2 participants