From 1fd9cbe05fc3962374fa3990c95e905cd450ed94 Mon Sep 17 00:00:00 2001 From: Saurabh Chavan Date: Wed, 16 Sep 2026 16:10:55 +0530 Subject: [PATCH 1/4] fix: fixed data not rendered issue for gallery widget --- .../gallery-native/CHANGELOG.md | 2 + .../gallery-native/package.json | 2 +- .../gallery-native/src/components/Gallery.tsx | 56 ++++++++- .../__snapshots__/Gallery.spec.tsx.snap | 114 +++++++++++++++++- .../gallery-native/src/package.xml | 2 +- 5 files changed, 164 insertions(+), 12 deletions(-) diff --git a/packages/pluggableWidgets/gallery-native/CHANGELOG.md b/packages/pluggableWidgets/gallery-native/CHANGELOG.md index 18940f590..1ee503bbf 100644 --- a/packages/pluggableWidgets/gallery-native/CHANGELOG.md +++ b/packages/pluggableWidgets/gallery-native/CHANGELOG.md @@ -6,6 +6,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), ## [Unreleased] +- We've fixed an issue where Gallery widget does not display data. + ## [2.1.0] - 2026-4-10 ### Changed diff --git a/packages/pluggableWidgets/gallery-native/package.json b/packages/pluggableWidgets/gallery-native/package.json index 57b21044d..af527cd31 100644 --- a/packages/pluggableWidgets/gallery-native/package.json +++ b/packages/pluggableWidgets/gallery-native/package.json @@ -1,7 +1,7 @@ { "name": "gallery-native", "widgetName": "Gallery", - "version": "2.1.0", + "version": "2.2.0", "description": "A flexible gallery widget that renders columns, rows and layouts.", "copyright": "© Mendix Technology BV 2022. All rights reserved.", "license": "Apache-2.0", diff --git a/packages/pluggableWidgets/gallery-native/src/components/Gallery.tsx b/packages/pluggableWidgets/gallery-native/src/components/Gallery.tsx index 956a1cfc1..d4f2e3274 100644 --- a/packages/pluggableWidgets/gallery-native/src/components/Gallery.tsx +++ b/packages/pluggableWidgets/gallery-native/src/components/Gallery.tsx @@ -1,5 +1,14 @@ -import { ReactElement, ReactNode, useCallback, useMemo } from "react"; -import { Text, Pressable, View, ViewProps, Platform, TouchableOpacity, useWindowDimensions } from "react-native"; +import { ReactElement, ReactNode, useCallback, useEffect, useMemo, useRef, useState } from "react"; +import { + LayoutChangeEvent, + Text, + Pressable, + View, + ViewProps, + Platform, + TouchableOpacity, + useWindowDimensions +} from "react-native"; import { ObjectItem, DynamicValue } from "mendix"; import DeviceInfo from "react-native-device-info"; import { GalleryStyle } from "../ui/Styles"; @@ -35,6 +44,13 @@ export const Gallery = (props: GalleryProps): ReactElem const lastItemId = props.items?.[props.items.length - 1]?.id; const { name, style, itemRenderer } = props; const { width } = useWindowDimensions(); + // FlashList requires a non-zero height to render items (it's virtualized and needs viewport dimensions). + // When the parent provides height (e.g. via flex), we use flex: 1. When it doesn't (e.g. a Container + // widget with no flex/height), flex: 1 resolves to 0 and nothing renders. In that case, we fall back + // to minHeight based on FlashList's reported content size. This matches the ListView widget's approach. + const wrapperRef = useRef(null); + const [contentHeight, setContentHeight] = useState(0); + const [layoutDecision, setLayoutDecision] = useState<"minHeight" | "flex" | null>(null); const onEndReached = (): void => { if (props.pagination === "virtualScrolling" && props.hasMoreItems) { @@ -137,8 +153,39 @@ export const Gallery = (props: GalleryProps): ReactElem [props.style.emptyPlaceholder, props.emptyPlaceholder] ); + const handleWrapperLayout = useCallback( + (event: LayoutChangeEvent) => { + const { height } = event.nativeEvent.layout; + if (height > 0 && layoutDecision === null) { + setLayoutDecision("flex"); + } + }, + [layoutDecision] + ); + + useEffect(() => { + if (contentHeight > 0 && layoutDecision === null && wrapperRef.current) { + wrapperRef.current.measure((_x, _y, _width, height) => { + setLayoutDecision(height > 0 ? "flex" : "minHeight"); + }); + } + }, [contentHeight, layoutDecision]); + + const containerStyle = isScrollDirectionVertical + ? layoutDecision === "minHeight" + ? [{ minHeight: Math.max(contentHeight, 1) }, props.style.container] + : [{ flex: 1 }, props.style.container] + : props.style.container; + + const listStyle = isScrollDirectionVertical ? [{ flex: 1 }, props.style.list] : props.style.list; + return ( - + {props.filters ? {props.filters} : null} (props: GalleryProps): ReactElem onEndReachedThreshold={0.6} scrollEventThrottle={50} renderItem={renderItem} - style={props.style.list} + style={listStyle} testID={`${name}-list`} + onContentSizeChange={isScrollDirectionVertical ? (_w, h) => setContentHeight(h) : undefined} /> ); diff --git a/packages/pluggableWidgets/gallery-native/src/components/__tests__/__snapshots__/Gallery.spec.tsx.snap b/packages/pluggableWidgets/gallery-native/src/components/__tests__/__snapshots__/Gallery.spec.tsx.snap index 8665fd92e..633141b5b 100644 --- a/packages/pluggableWidgets/gallery-native/src/components/__tests__/__snapshots__/Gallery.spec.tsx.snap +++ b/packages/pluggableWidgets/gallery-native/src/components/__tests__/__snapshots__/Gallery.spec.tsx.snap @@ -2,7 +2,15 @@ exports[`Gallery rendering rendering with load more button it shouldn't render the paging button if hasn't more item 1`] = ` @@ -178,7 +195,15 @@ exports[`Gallery rendering rendering with load more button it shouldn't render t exports[`Gallery rendering rendering with load more button renders correctly 1`] = ` @@ -399,7 +433,15 @@ exports[`Gallery rendering rendering with load more button renders correctly 1`] exports[`Gallery rendering rendering with load more button renders correctly with custom paging button title 1`] = ` @@ -620,7 +671,15 @@ exports[`Gallery rendering rendering with load more button renders correctly wit exports[`Gallery rendering renders correctly 1`] = ` @@ -1016,7 +1084,15 @@ exports[`Gallery rendering renders correctly horizontal 1`] = ` exports[`Gallery rendering renders correctly with empty list and custom placeholder 1`] = ` @@ -1045,7 +1130,15 @@ exports[`Gallery rendering renders correctly with empty list and custom placehol exports[`Gallery rendering renders correctly with filter 1`] = ` @@ -1060,9 +1153,18 @@ exports[`Gallery rendering renders correctly with filter 1`] = ` horizontal={false} keyExtractor={[Function]} numColumns={2} + onContentSizeChange={[Function]} onEndReached={[Function]} onEndReachedThreshold={0.6} scrollEventThrottle={50} + style={ + [ + { + "flex": 1, + }, + undefined, + ] + } testID="gallery-test-list" > diff --git a/packages/pluggableWidgets/gallery-native/src/package.xml b/packages/pluggableWidgets/gallery-native/src/package.xml index 131f3fb0a..96b25783b 100644 --- a/packages/pluggableWidgets/gallery-native/src/package.xml +++ b/packages/pluggableWidgets/gallery-native/src/package.xml @@ -1,6 +1,6 @@ - + From c179e3bec48835f21d45e19812dbefdc9da32c14 Mon Sep 17 00:00:00 2001 From: Saurabh Chavan Date: Thu, 17 Sep 2026 18:08:39 +0530 Subject: [PATCH 2/4] fix: added logic to calculate height of flashlist --- .../gallery-native/src/components/Gallery.tsx | 65 ++++++++++--------- 1 file changed, 33 insertions(+), 32 deletions(-) diff --git a/packages/pluggableWidgets/gallery-native/src/components/Gallery.tsx b/packages/pluggableWidgets/gallery-native/src/components/Gallery.tsx index d4f2e3274..54c2de07c 100644 --- a/packages/pluggableWidgets/gallery-native/src/components/Gallery.tsx +++ b/packages/pluggableWidgets/gallery-native/src/components/Gallery.tsx @@ -47,8 +47,8 @@ export const Gallery = (props: GalleryProps): ReactElem // FlashList requires a non-zero height to render items (it's virtualized and needs viewport dimensions). // When the parent provides height (e.g. via flex), we use flex: 1. When it doesn't (e.g. a Container // widget with no flex/height), flex: 1 resolves to 0 and nothing renders. In that case, we fall back - // to minHeight based on FlashList's reported content size. This matches the ListView widget's approach. - const wrapperRef = useRef(null); + // to minHeight based on FlashList's reported content size. We measure the FlashList area specifically so we get the height of the list area, not the entire Gallery (which may include filters and padding). + const listAreaRef = useRef(null); const [contentHeight, setContentHeight] = useState(0); const [layoutDecision, setLayoutDecision] = useState<"minHeight" | "flex" | null>(null); @@ -153,7 +153,7 @@ export const Gallery = (props: GalleryProps): ReactElem [props.style.emptyPlaceholder, props.emptyPlaceholder] ); - const handleWrapperLayout = useCallback( + const handleListAreaLayout = useCallback( (event: LayoutChangeEvent) => { const { height } = event.nativeEvent.layout; if (height > 0 && layoutDecision === null) { @@ -164,8 +164,8 @@ export const Gallery = (props: GalleryProps): ReactElem ); useEffect(() => { - if (contentHeight > 0 && layoutDecision === null && wrapperRef.current) { - wrapperRef.current.measure((_x, _y, _width, height) => { + if (contentHeight > 0 && layoutDecision === null && listAreaRef.current) { + listAreaRef.current.measure((_x, _y, _width, height) => { setLayoutDecision(height > 0 ? "flex" : "minHeight"); }); } @@ -180,34 +180,35 @@ export const Gallery = (props: GalleryProps): ReactElem const listStyle = isScrollDirectionVertical ? [{ flex: 1 }, props.style.list] : props.style.list; return ( - + {props.filters ? {props.filters} : null} - item.id} - ListEmptyComponent={renderEmptyPlaceholder} - onEndReached={onEndReached} - onEndReachedThreshold={0.6} - scrollEventThrottle={50} - renderItem={renderItem} - style={listStyle} - testID={`${name}-list`} - onContentSizeChange={isScrollDirectionVertical ? (_w, h) => setContentHeight(h) : undefined} - /> + + item.id} + ListEmptyComponent={renderEmptyPlaceholder} + onEndReached={onEndReached} + onEndReachedThreshold={0.6} + scrollEventThrottle={50} + renderItem={renderItem} + style={listStyle} + testID={`${name}-list`} + onContentSizeChange={isScrollDirectionVertical ? (_w, h) => setContentHeight(h) : undefined} + /> + ); }; From d977b87ec7c392377d70bbaa64b2f12b9541ca9d Mon Sep 17 00:00:00 2001 From: Saurabh Chavan Date: Thu, 17 Sep 2026 18:17:05 +0530 Subject: [PATCH 3/4] fix: unit testcases snapshot updated --- .../__snapshots__/Gallery.spec.tsx.snap | 1926 +++++++++-------- 1 file changed, 988 insertions(+), 938 deletions(-) diff --git a/packages/pluggableWidgets/gallery-native/src/components/__tests__/__snapshots__/Gallery.spec.tsx.snap b/packages/pluggableWidgets/gallery-native/src/components/__tests__/__snapshots__/Gallery.spec.tsx.snap index 633141b5b..aa845444f 100644 --- a/packages/pluggableWidgets/gallery-native/src/components/__tests__/__snapshots__/Gallery.spec.tsx.snap +++ b/packages/pluggableWidgets/gallery-native/src/components/__tests__/__snapshots__/Gallery.spec.tsx.snap @@ -2,7 +2,6 @@ exports[`Gallery rendering rendering with load more button it shouldn't render the paging button if hasn't more item 1`] = ` - - + + - 11 + + 11 + - - - + - 22 + + 22 + - - - + - 33 + + 33 + - - - + - 44 + + 44 + - - - + - 55 + + 55 + - - - + - 66 + + 66 + - - - + - 77 + + 77 + - - - + - 88 + + 88 + - - - + - 99 + + 99 + @@ -195,7 +203,6 @@ exports[`Gallery rendering rendering with load more button it shouldn't render t exports[`Gallery rendering rendering with load more button renders correctly 1`] = ` - - + + - 11 + + 11 + - - - + - 22 + + 22 + - - - + - 33 + + 33 + - - - + - 44 + + 44 + - - - + - 55 + + 55 + - - - + - 66 + + 66 + - - - + - 77 + + 77 + - - - + - 88 + + 88 + - - - + - 99 + + 99 + - - - - Load more - + onBlur={[Function]} + onClick={[Function]} + onFocus={[Function]} + onResponderGrant={[Function]} + onResponderMove={[Function]} + onResponderRelease={[Function]} + onResponderTerminate={[Function]} + onResponderTerminationRequest={[Function]} + onStartShouldSetResponder={[Function]} + style={{}} + testID="gallery-test-pagination-button" + > + + Load more + + @@ -433,7 +449,6 @@ exports[`Gallery rendering rendering with load more button renders correctly 1`] exports[`Gallery rendering rendering with load more button renders correctly with custom paging button title 1`] = ` - - + + - 11 + + 11 + - - - + - 22 + + 22 + - - - + - 33 + + 33 + - - - + - 44 + + 44 + - - - + - 55 + + 55 + - - - + - 66 + + 66 + - - - + - 77 + + 77 + - - - + - 88 + + 88 + - - - + - 99 + + 99 + - - - - Show more - + onBlur={[Function]} + onClick={[Function]} + onFocus={[Function]} + onResponderGrant={[Function]} + onResponderMove={[Function]} + onResponderRelease={[Function]} + onResponderTerminate={[Function]} + onResponderTerminationRequest={[Function]} + onStartShouldSetResponder={[Function]} + style={{}} + testID="gallery-test-pagination-button" + > + + Show more + + @@ -671,7 +695,6 @@ exports[`Gallery rendering rendering with load more button renders correctly wit exports[`Gallery rendering renders correctly 1`] = ` - - + + - 11 + + 11 + - - - + - 22 + + 22 + - - - + - 33 + + 33 + - - - + - 44 + + 44 + - - - + - 55 + + 55 + - - - + - 66 + + 66 + - - - + - 77 + + 77 + - - - + - 88 + + 88 + - - - + - 99 + + 99 + @@ -867,214 +899,216 @@ exports[`Gallery rendering renders correctly horizontal 1`] = ` style={{}} testID="gallery-test" > - - - + + } + horizontal={true} + keyExtractor={[Function]} + onEndReached={[Function]} + onEndReachedThreshold={0.6} + scrollEventThrottle={50} + testID="gallery-test-list" + > + - 11 + + 11 + - - - + - 22 + + 22 + - - - + - 33 + + 33 + - - - + - 44 + + 44 + - - - + - 55 + + 55 + - - - + - 66 + + 66 + - - - + - 77 + + 77 + - - - + - 88 + + 88 + - - - + - 99 + + 99 + @@ -1084,7 +1118,6 @@ exports[`Gallery rendering renders correctly horizontal 1`] = ` exports[`Gallery rendering renders correctly with empty list and custom placeholder 1`] = ` - - - Empty list... - + + + + Empty list... + + @@ -1130,7 +1172,6 @@ exports[`Gallery rendering renders correctly with empty list and custom placehol exports[`Gallery rendering renders correctly with filter 1`] = ` - - + + - 11 + + 11 + - - - + - 22 + + 22 + - - - + - 33 + + 33 + - - - + - 44 + + 44 + - - - + - 55 + + 55 + - - - + - 66 + + 66 + - - - + - 77 + + 77 + - - - + - 88 + + 88 + - - - + - 99 + + 99 + From 58ed45b76a3e789de9de3a1c93954bc13ecf7b7a Mon Sep 17 00:00:00 2001 From: Saurabh Chavan Date: Thu, 17 Sep 2026 18:25:27 +0530 Subject: [PATCH 4/4] fix: update widget version --- packages/pluggableWidgets/gallery-native/package.json | 2 +- packages/pluggableWidgets/gallery-native/src/package.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/pluggableWidgets/gallery-native/package.json b/packages/pluggableWidgets/gallery-native/package.json index af527cd31..5360338e4 100644 --- a/packages/pluggableWidgets/gallery-native/package.json +++ b/packages/pluggableWidgets/gallery-native/package.json @@ -1,7 +1,7 @@ { "name": "gallery-native", "widgetName": "Gallery", - "version": "2.2.0", + "version": "2.1.1", "description": "A flexible gallery widget that renders columns, rows and layouts.", "copyright": "© Mendix Technology BV 2022. All rights reserved.", "license": "Apache-2.0", diff --git a/packages/pluggableWidgets/gallery-native/src/package.xml b/packages/pluggableWidgets/gallery-native/src/package.xml index 96b25783b..cc5b9921c 100644 --- a/packages/pluggableWidgets/gallery-native/src/package.xml +++ b/packages/pluggableWidgets/gallery-native/src/package.xml @@ -1,6 +1,6 @@ - +