Skip to content

Commit f28a77d

Browse files
committed
Close #1118. Update data frame renderer to work properly with fill/fillable
1 parent fb8b587 commit f28a77d

File tree

6 files changed

+19
-10
lines changed

6 files changed

+19
-10
lines changed

js/dataframe/index.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ interface ShinyDataGridProps<TIndex> {
5959
const ShinyDataGrid: FC<ShinyDataGridProps<unknown>> = (props) => {
6060
const { id, data, bgcolor } = props;
6161
const { columns, type_hints, data: rowData } = data;
62-
const { width, height, filters: withFilters } = data.options;
62+
const { width, height, fill, filters: withFilters } = data.options;
6363

6464
const containerRef = useRef<HTMLDivElement>(null);
6565
const theadRef = useRef<HTMLTableSectionElement>(null);
@@ -227,10 +227,15 @@ const ShinyDataGrid: FC<ShinyDataGridProps<unknown>> = (props) => {
227227

228228
const measureEl = useVirtualizerMeasureWorkaround(rowVirtualizer);
229229

230+
let className = `shiny-data-grid ${containerClass} ${scrollingClass}`;
231+
if (fill) {
232+
className += " html-fill-item";
233+
}
234+
230235
return (
231236
<>
232237
<div
233-
className={`shiny-data-grid ${containerClass} ${scrollingClass}`}
238+
className={className}
234239
ref={containerRef}
235240
style={{ width, maxHeight: height, overflow: "auto" }}
236241
>

js/dataframe/styles.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838

3939
.shiny-data-grid {
4040
max-width: 100%;
41+
height: 500px;
4142

4243
> table {
4344
border-collapse: separate;

js/dataframe/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ export interface DataGridOptions {
1616
filters?: boolean;
1717
width?: string;
1818
height?: string;
19+
fill?: boolean;
1920
}
2021

2122
export interface PandasData<TIndex> {

shiny/render/_dataframe.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ def __init__(
7474
data: object,
7575
*,
7676
width: str | float | None = "fit-content",
77-
height: Union[str, float, None] = "500px",
77+
height: Union[str, float, None] = None,
7878
summary: Union[bool, str] = True,
7979
filters: bool = False,
8080
row_selection_mode: Literal["none", "single", "multiple"] = "none",
@@ -193,6 +193,7 @@ def to_payload(self) -> Jsonifiable:
193193
filters=self.filters,
194194
row_selection_mode=self.row_selection_mode,
195195
style="table",
196+
fill=self.height is None,
196197
)
197198
return res
198199

shiny/www/shared/py-shiny/dataframe/dataframe.js

Lines changed: 5 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

shiny/www/shared/py-shiny/dataframe/dataframe.js.map

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)