Skip to content

feat: allow passing minHeight and minWidth to contentContainerStyle #1560

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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ and adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [Unreleased]

- Allow `minWidth` and `minHeight` to be passed to `contentContainerStyle`
- https://github.com/Shopify/flash-list/pull/1560

## [1.7.6] - 2025-03-19

- Fix React 18 ref error
Expand Down
2 changes: 2 additions & 0 deletions documentation/docs/fundamentals/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,8 @@ export type ContentStyle = Pick<
| "padding"
| "paddingVertical"
| "paddingHorizontal"
| "minWidth"
| "minHeight"
>;
```

Expand Down
4 changes: 2 additions & 2 deletions src/FlashList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -357,8 +357,8 @@ class FlashList<T> extends React.PureComponent<
backgroundColor: this.contentStyle.backgroundColor,

// Required to handle a scrollview bug. Check: https://github.com/Shopify/flash-list/pull/187
minHeight: 1,
minWidth: 1,
minHeight: this.contentStyle.minHeight || 1,
minWidth: this.contentStyle.minWidth || 1,

...getContentContainerPadding(this.contentStyle, horizontal),
},
Expand Down
2 changes: 2 additions & 0 deletions src/FlashListProps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ export type ContentStyle = Pick<
| "padding"
| "paddingVertical"
| "paddingHorizontal"
| "minHeight"
| "minWidth"
>;

export interface FlashListProps<TItem> extends ScrollViewProps {
Expand Down
6 changes: 6 additions & 0 deletions src/utils/ContentContainerUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import { Dimension } from "recyclerlistview";
import { ContentStyle } from "../FlashListProps";

export interface ContentStyleExplicit {
minWidth: number;
minHeight: number;
paddingTop: number;
paddingBottom: number;
paddingLeft: number;
Expand All @@ -24,6 +26,8 @@ export const updateContentStyle = (
paddingVertical,
paddingHorizontal,
backgroundColor,
minWidth,
minHeight,
} = (contentContainerStyleSource ?? {}) as ViewStyle;
contentStyle.paddingLeft = Number(
paddingLeft || paddingHorizontal || padding || 0
Expand All @@ -38,6 +42,8 @@ export const updateContentStyle = (
paddingBottom || paddingVertical || padding || 0
);
contentStyle.backgroundColor = backgroundColor;
contentStyle.minWidth = Number(minWidth || 0);
contentStyle.minHeight = Number(minHeight || 0);
return contentStyle as ContentStyleExplicit;
};

Expand Down