Skip to content
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
4 changes: 4 additions & 0 deletions packages/pluggableWidgets/gallery-native/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),

## [Unreleased]

### Fixed

- We've fixed an issue where pull to refresh did not work when the Gallery widget had no items and only showed the empty placeholder.

## [2.4.0] - 2026-11-25

### Fixed
Expand Down
2 changes: 1 addition & 1 deletion packages/pluggableWidgets/gallery-native/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "gallery-native",
"widgetName": "Gallery",
"version": "2.4.0",
"version": "2.4.1",
"description": "A flexible gallery widget that renders columns, rows and layouts.",
"copyright": "© Mendix Technology BV 2022. All rights reserved.",
"license": "Apache-2.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import {
View,
ViewProps,
Platform,
RefreshControl,
ScrollView,
TouchableOpacity,
useWindowDimensions
} from "react-native";
Expand Down Expand Up @@ -154,10 +156,32 @@ export const Gallery = <T extends ObjectItem>(props: GalleryProps<T>): ReactElem
props.loadMoreItems
]);

const renderEmptyPlaceholder = useMemo(
(): ReactElement => <View style={props.style.emptyPlaceholder}>{props.emptyPlaceholder}</View>,
[props.style.emptyPlaceholder, props.emptyPlaceholder]
);
const renderEmptyPlaceholder = useMemo((): ReactElement => {
const placeholder = <View style={props.style.emptyPlaceholder}>{props.emptyPlaceholder}</View>;
// Without items FlashList is not rendered, so wrap the placeholder in a scroll container
// to keep pull-to-refresh available on an empty gallery.
if (isScrollDirectionVertical && props.pullDown) {
return (
<ScrollView
testID={`${name}-empty-placeholder`}
contentContainerStyle={{ flexGrow: 1 }}
refreshControl={
<RefreshControl refreshing={!!props.pullDownIsExecuting} onRefresh={props.pullDown} />
}
>
{placeholder}
</ScrollView>
);
}
return placeholder;
}, [
props.style.emptyPlaceholder,
props.emptyPlaceholder,
isScrollDirectionVertical,
props.pullDown,
props.pullDownIsExecuting,
name
]);

const onContentSizeChange = useCallback((_width: number, height: number): void => {
if (height > 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,29 @@ describe("Gallery", () => {
expect(pullDown).toHaveBeenCalledTimes(1);
});

it("triggers pull down action when list is empty", async () => {
const pullDown = jest.fn();
const galleryComponent = render(
<Gallery
{...defaultProps}
scrollDirection="vertical"
items={[]}
hasMoreItems={false}
emptyPlaceholder={<Text>Empty list...</Text>}
pullDown={pullDown}
pullDownIsExecuting={false}
/>
);
const emptyPlaceholder = galleryComponent.getByTestId("gallery-test-empty-placeholder");
expect(galleryComponent.getByText("Empty list...")).toBeDefined();

const { refreshControl } = emptyPlaceholder.props;
await act(async () => {
refreshControl.props.onRefresh();
});
expect(pullDown).toHaveBeenCalledTimes(1);
});

it("triggers load more items events on end reached", () => {
const gallery = render(<Gallery {...defaultProps} />);
const galleryList = gallery.getByTestId("gallery-test-list");
Expand Down
2 changes: 1 addition & 1 deletion packages/pluggableWidgets/gallery-native/src/package.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<package xmlns="http://www.mendix.com/package/1.0/">
<clientModule name="Gallery" version="2.4.0" xmlns="http://www.mendix.com/clientModule/1.0/">
<clientModule name="Gallery" version="2.4.1" xmlns="http://www.mendix.com/clientModule/1.0/">
<widgetFiles>
<widgetFile path="Gallery.xml" />
</widgetFiles>
Expand Down
Loading