diff --git a/src/components/SelectionList/BaseSelectionList.tsx b/src/components/SelectionList/BaseSelectionList.tsx index 3e0ca80b5e41..897bbb6faad0 100644 --- a/src/components/SelectionList/BaseSelectionList.tsx +++ b/src/components/SelectionList/BaseSelectionList.tsx @@ -77,6 +77,7 @@ function BaseSelectionList( sectionTitleStyles, textInputAutoFocus = true, shouldTextInputInterceptSwipe = false, + listHeaderContent, onEndReached = () => {}, onEndReachedThreshold, }: BaseSelectionListProps, @@ -334,7 +335,7 @@ function BaseSelectionList( return ; } - if (!section.title || isEmptyObject(section.data)) { + if (!section.title || isEmptyObject(section.data) || listHeaderContent) { return null; } @@ -349,6 +350,39 @@ function BaseSelectionList( ); }; + const header = () => ( + <> + {!headerMessage && canSelectMultiple && shouldShowSelectAll && ( + + + + {!customListHeader && ( + e.preventDefault() : undefined} + > + {translate('workspace.people.selectAll')} + + )} + + {customListHeader} + + )} + {!headerMessage && !canSelectMultiple && customListHeader} + + ); + const renderItem = ({item, index, section}: SectionListRenderItemInfo>) => { const normalizedIndex = index + (section?.indexOffset ?? 0); const isDisabled = !!section.isDisabled || item.isDisabled; @@ -580,39 +614,17 @@ function BaseSelectionList( ) : ( <> - {!headerMessage && canSelectMultiple && shouldShowSelectAll && ( - - - - {!customListHeader && ( - e.preventDefault() : undefined} - > - {translate('workspace.people.selectAll')} - - )} - - {customListHeader} - - )} - {!headerMessage && !canSelectMultiple && customListHeader} + {!listHeaderContent && header()} ( + <> + {renderSectionHeader(arg)} + {listHeaderContent && header()} + + )} renderItem={renderItem} getItemLayout={getItemLayout} onScroll={onScroll} @@ -631,6 +643,7 @@ function BaseSelectionList( onLayout={onSectionListLayout} style={(!maxToRenderPerBatch || (shouldHideListOnInitialRender && isInitialSectionListRender)) && styles.opacity0} ListFooterComponent={listFooterContent ?? ShowMoreButtonInstance} + ListHeaderComponent={listHeaderContent && listHeaderContent} onEndReached={onEndReached} onEndReachedThreshold={onEndReachedThreshold} /> diff --git a/src/components/SelectionList/types.ts b/src/components/SelectionList/types.ts index 0a4b0532b581..4c9b72634c46 100644 --- a/src/components/SelectionList/types.ts +++ b/src/components/SelectionList/types.ts @@ -321,6 +321,9 @@ type BaseSelectionListProps = Partial & { /** Custom content to display in the header */ headerContent?: ReactNode; + /** Custom content to display in the header of list component. */ + listHeaderContent?: React.JSX.Element | null; + /** Custom content to display in the footer */ footerContent?: ReactNode; diff --git a/src/pages/workspace/WorkspaceMembersPage.tsx b/src/pages/workspace/WorkspaceMembersPage.tsx index 3c14e4332081..fe88c12e6776 100644 --- a/src/pages/workspace/WorkspaceMembersPage.tsx +++ b/src/pages/workspace/WorkspaceMembersPage.tsx @@ -504,7 +504,7 @@ function WorkspaceMembersPage({personalDetails, invitedEmailsToAccountIDsDraft, onPress={() => null} options={getBulkActionsButtonOptions()} isSplitButton={false} - style={[isSmallScreenWidth && styles.flexGrow1]} + style={[isSmallScreenWidth && styles.flexGrow1, isSmallScreenWidth && styles.mb3]} /> ) : (