Skip to content
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

FIx group chat confirmation list is displayed with delay #39364

Merged
Show file tree
Hide file tree
Changes from 6 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: 2 additions & 1 deletion src/components/SelectionList/BaseSelectionList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ function BaseSelectionList<TItem extends ListItem>(
isRowMultilineSupported = false,
textInputRef,
headerMessageStyle,
shouldHideListOnInitialRender = true,
}: BaseSelectionListProps<TItem>,
ref: ForwardedRef<SelectionListHandle>,
) {
Expand Down Expand Up @@ -572,7 +573,7 @@ function BaseSelectionList<TItem extends ListItem>(
viewabilityConfig={{viewAreaCoveragePercentThreshold: 95}}
testID="selection-list"
onLayout={onSectionListLayout}
style={(!maxToRenderPerBatch || isInitialSectionListRender) && styles.opacity0}
style={(!maxToRenderPerBatch || (shouldHideListOnInitialRender && isInitialSectionListRender)) && styles.opacity0}
ListFooterComponent={ShowMoreButtonInstance}
/>
{children}
Expand Down
3 changes: 3 additions & 0 deletions src/components/SelectionList/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,9 @@ type BaseSelectionListProps<TItem extends ListItem> = Partial<ChildrenProps> & {

/** Ref for textInput */
textInputRef?: MutableRefObject<TextInput | null>;

/** Whether to hide the list on the initial render. This would prevent the list from "blinking" when you have a long list and it auto scrolls to the bottom on mount but will delay the showing of the list */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is better thanks! Here is a suggestion that could improve it a little more:

When true, the list won't be visible until all items are rendered. This prevents the list from "blinking" as it's scrolled to the bottom which is recommended for large lists. When false, the list will render immediately and scroll to the bottom which works great for small lists.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great. Updated with a little modification.

-When true, the list won't be visible until all items are rendered.
+When true, the list won't be visible until the list layout is measured

because the isInitialSectionListRender is set to false in onLayout of the list

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love it, thanks!

shouldHideListOnInitialRender?: boolean;
};

type SelectionListHandle = {
Expand Down
1 change: 1 addition & 0 deletions src/pages/NewChatConfirmPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ function NewChatConfirmPage({newGroupDraft, allPersonalDetails}: NewChatConfirmP
showConfirmButton={selectedOptions.length > 1}
confirmButtonText={translate('newChatPage.startGroup')}
onConfirm={createGroup}
shouldHideListOnInitialRender={false}
/>
</ScreenWrapper>
);
Expand Down
Loading