Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

resizable = TRUE removes the break in the underline between adjacent colGroups #396

Open
wvictor14 opened this issue Oct 31, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@wvictor14
Copy link

wvictor14 commented Oct 31, 2024

The underline underneath colGroups gets extended such that there is no "break" between adjacent colGroups, making it difficult to discern between adjacent colGroups

resizable = FALSE (default)

reactable(
    iris,
    columns = list(
        Sepal.Length = colDef(name = "Length"),
        Sepal.Width = colDef(name = "Width"),
        Petal.Length = colDef(name = "Length"),
        Petal.Width = colDef(name = "Width")
    ),
    columnGroups = list(
        colGroup(name = "Sepal", columns = c("Sepal.Length", "Sepal.Width")),
        colGroup(name = "Petal", columns = c("Petal.Length", "Petal.Width"))
    )
)

image

resizable = TRUE

reactable::reactable(
    iris,
    resizable = TRUE,
    columns = list(
        Sepal.Length = colDef(name = "Length"),
        Sepal.Width = colDef(name = "Width"),
        Petal.Length = colDef(name = "Length"),
        Petal.Width = colDef(name = "Width")
    ),
    columnGroups = list(
        colGroup(name = "Sepal", columns = c("Sepal.Length", "Sepal.Width")),
        colGroup(name = "Petal", columns = c("Petal.Length", "Petal.Width"))
    )
)

image

I am not good with CSS, so could not figure out how to reintroduce the underline, which I thought would be something to the effect of modifying "margin" and/or "bottom-border" using the headerStyle argument of colGroup.

@glin glin added the bug Something isn't working label Dec 2, 2024
@glin
Copy link
Owner

glin commented Dec 2, 2024

Good catch, I knew about some spacing inconsistencies with the column group headers before, but never noticed the spacing was fully extended on resizable tables. This is a weird one to fix because column group headers don't use real borders like regular headers do. The borders are faked in order to achieve that spacing in between groups, with this CSS:

.rt-th-group::after {
  /* Custom borders with spacing */
  content: '';
  position: absolute;
  margin: auto;
  left: 8px;
  right: 8px;
  bottom: 0;
  width: 100%;
  height: 1px;
  background-color: hsl(0, 0%, 90%);
}

The problem was the width: 100% CSS, combined with resizable headers actually extending outside of their bounds for a larger resize mouse target. Removing width: 100% seems to fix this, but it'll probably need more testing on browsers to be sure. I don't remember if there was a specific reason the width was set like that.

If you want to try this, here's a branch that can be installed for now: https://github.com/glin/reactable/compare/fix-group-borders?expand=1

remotes::install_github("glin/reactable@fix-group-borders")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants