Skip to content

Commit 1f23738

Browse files
committed
Update layout_column_width(fixed_width) param's min width.
Related to rstudio/bslib#851
1 parent 83e867c commit 1f23738

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ Methods still under consideration in `shiny.experimental.ui`:
7474
* Fixed #676: The `render.data_frame` selection feature was underdocumented and buggy (sometimes returning `None` as a row identifier if the pandas data frame's index had gaps in it). With this release, the selection is consistently a tuple of the 0-based row numbers of the selected rows--or `None` if no rows are selected. (#677)
7575
* Added tests to verify that ui input methods, ui labels, ui update (value) methods, and ui output methods work within modules (#696).
7676
* Adjusted the `@render.plot` input type to be `object` to allow for any object (if any) to be returned (#712).
77+
* In `layout_column_wrap()`, when `width` is a CSS unit -- e.g. `width = "400px"` or `width = "25%"` -- and `fixed_width = FALSE`, `layout_column_wrap()` will ensure that the columns are at least `width` wide, unless the parent container is narrower than `width`. (#772)
7778

7879
### Other changes
7980

shiny/ui/_layout.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,13 @@ def layout_column_wrap(
4848
:func:`~shiny.ui.card`). Named arguments become attributes on the
4949
containing :class:`~htmltools.Tag` element.
5050
fixed_width
51-
Whether or not to interpret the `width` as a minimum (`fixed_width=False`) or
52-
fixed (`fixed_width=True`) width when it is a CSS length unit.
51+
When `width` is greater than 1 or is a CSS length unit, e.g. `"200px"`,
52+
`fixed_width` indicates whether that `width` value represents the absolute size
53+
of each column (`fixed_width=TRUE`) or the minimum size of a column
54+
(`fixed_width=FALSE`). When `fixed_width=FALSE`, new columns are added to a row
55+
when `width` space is available and columns will never exceed the container or
56+
viewport size. When `fixed_width=TRUE`, all columns will be exactly `width`
57+
wide, which may result in columns overflowing the parent container.
5358
heights_equal
5459
If `"all"` (the default), every card in every row of the grid will have the same
5560
height. If `"row"`, then every card in _each_ row of the grid will have the same
@@ -92,7 +97,7 @@ def layout_column_wrap(
9297
if fixed_width:
9398
colspec = f"repeat(auto-fit, minmax({width_css_unit}, 1fr))"
9499
else:
95-
colspec = f"repeat(auto-fit, minmax(0, {width_css_unit}))"
100+
colspec = f"repeat(auto-fit, minmax(min({width_css_unit}, 100%), 1fr))"
96101

97102
# Use a new dict so that we don't mutate the original `children` dict
98103
upgraded_children: list[TagChild] = []

0 commit comments

Comments
 (0)