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

Fill containers clip child content #386

Closed
gadenbuie opened this issue Jul 18, 2023 · 0 comments · Fixed by #387
Closed

Fill containers clip child content #386

gadenbuie opened this issue Jul 18, 2023 · 0 comments · Fixed by #387
Assignees

Comments

@gadenbuie
Copy link
Member

gadenbuie commented Jul 18, 2023

We currently use overflow: auto in .html-fill-container classes, which has the unfortunate side-effect of clipping the content of child containers. Instead, we can set min-width: 0 and min-height: 0 to achieve a similar effect.

ChatGPT summarizes this approach well:

Using min-height: 0 or min-width: 0 (or both) on a flex container is a common technique in CSS to prevent the container from expanding vertically or horizontally beyond its parent's constraints. When a flex container has a fixed size parent or is nested within other flexible elements, it may encounter issues with overflowing content or unexpected alignment behavior.

By setting min-height: 0 or min-width: 0, it essentially resets the minimum height or width constraint on the flex container, allowing it to shrink and accommodate its contents properly. This is especially useful when dealing with flex items that have a flex-shrink property set, making them capable of shrinking beyond their content's intrinsic size.

Here's a minimal reprex using the existing fill.css. We want the shadow on the child container to appear in both examples, but without explicitly setting overflow: visible (as in the second card where it's shown as expected).

library(htmltools)
library(bslib)

page_fixed(
  bindFillRole(
    container = TRUE,
    div(
      class = "m-3 float-left",
      style = css(height = "300px", width = "300px"),
      bindFillRole(
        div(class = "border border-2 shadow"),
        item = TRUE
      )
    )
  ),
  bindFillRole(
    container = TRUE,
    div(
      class = "overflow-visible",
      class = "m-3 float-left",
      style = css(height = "300px", width = "300px"),
      bindFillRole(
        div(class = "border border-2 shadow"),
        item = TRUE
      )
    )
  )
)

image

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 a pull request may close this issue.

1 participant