Skip to content

Commit

Permalink
Merge pull request #32665 from brunovjk/fix/31779
Browse files Browse the repository at this point in the history
Fix Black Screen Transition Issue by Reusing didScreenTransitionEnd in MoneyRequestParticipantsSelector
  • Loading branch information
lakchote authored Jan 26, 2024
2 parents ff6b134 + 6c649a3 commit caf91ae
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import useThemeStyles from '@hooks/useThemeStyles';
import * as Report from '@libs/actions/Report';
import * as DeviceCapabilities from '@libs/DeviceCapabilities';
import * as OptionsListUtils from '@libs/OptionsListUtils';
import * as ReportUtils from '@libs/ReportUtils';
import reportPropTypes from '@pages/reportPropTypes';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
Expand Down Expand Up @@ -54,16 +55,16 @@ const propTypes = {
/** The request type, ie. manual, scan, distance */
iouRequestType: PropTypes.oneOf(_.values(CONST.IOU.REQUEST_TYPE)).isRequired,

/** Whether we are searching for reports in the server */
isSearchingForReports: PropTypes.bool,
/** Whether the parent screen transition has ended */
didScreenTransitionEnd: PropTypes.bool,
};

const defaultProps = {
participants: [],
safeAreaPaddingBottomStyle: {},
reports: {},
betas: [],
isSearchingForReports: false,
didScreenTransitionEnd: false,
};

function MoneyTemporaryForRefactorRequestParticipantsSelector({
Expand All @@ -75,7 +76,7 @@ function MoneyTemporaryForRefactorRequestParticipantsSelector({
safeAreaPaddingBottomStyle,
iouType,
iouRequestType,
isSearchingForReports,
didScreenTransitionEnd,
}) {
const {translate} = useLocalize();
const styles = useThemeStyles();
Expand All @@ -95,6 +96,9 @@ function MoneyTemporaryForRefactorRequestParticipantsSelector({
*/
const [sections, newChatOptions] = useMemo(() => {
const newSections = [];
if (!didScreenTransitionEnd) {
return [newSections, {}];
}
let indexOffset = 0;

const chatOptions = OptionsListUtils.getFilteredOptions(
Expand Down Expand Up @@ -169,7 +173,7 @@ function MoneyTemporaryForRefactorRequestParticipantsSelector({
}

return [newSections, chatOptions];
}, [reports, personalDetails, betas, searchTerm, participants, iouType, iouRequestType, maxParticipantsReached, translate]);
}, [didScreenTransitionEnd, reports, personalDetails, betas, searchTerm, participants, iouType, iouRequestType, maxParticipantsReached, translate]);

/**
* Adds a single participant to the request
Expand Down Expand Up @@ -328,11 +332,13 @@ function MoneyTemporaryForRefactorRequestParticipantsSelector({
[addParticipantToSelection, isAllowedToSplit, styles, translate],
);

const isOptionsDataReady = useMemo(() => ReportUtils.isReportDataReady() && OptionsListUtils.isPersonalDetailsReady(personalDetails), [personalDetails]);

return (
<View style={[styles.flex1, styles.w100, participants.length > 0 ? safeAreaPaddingBottomStyle : {}]}>
<SelectionList
onConfirm={handleConfirmSelection}
sections={sections}
sections={didScreenTransitionEnd && isOptionsDataReady ? sections : CONST.EMPTY_ARRAY}
textInputValue={searchTerm}
textInputLabel={translate('optionsSelector.nameEmailOrPhoneNumber')}
textInputHint={offlineMessage}
Expand All @@ -341,7 +347,7 @@ function MoneyTemporaryForRefactorRequestParticipantsSelector({
onSelectRow={addSingleParticipant}
footerContent={footerContent}
headerMessage={headerMessage}
showLoadingPlaceholder={isSearchingForReports}
showLoadingPlaceholder={!(didScreenTransitionEnd && isOptionsDataReady)}
rightHandSideComponent={itemRightSideComponent}
/>
</View>
Expand All @@ -359,8 +365,4 @@ export default withOnyx({
betas: {
key: ONYXKEYS.BETAS,
},
isSearchingForReports: {
key: ONYXKEYS.IS_SEARCHING_FOR_REPORTS,
initWithStoredValues: false,
},
})(MoneyTemporaryForRefactorRequestParticipantsSelector);
17 changes: 10 additions & 7 deletions src/pages/iou/request/step/IOURequestStepParticipants.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,16 @@ function IOURequestStepParticipants({
testID={IOURequestStepParticipants.displayName}
includeSafeAreaPaddingBottom
>
<MoneyRequestParticipantsSelector
participants={participants}
onParticipantsAdded={addParticipant}
onFinish={goToNextStep}
iouType={iouType}
iouRequestType={iouRequestType}
/>
{({didScreenTransitionEnd}) => (
<MoneyRequestParticipantsSelector
participants={participants}
onParticipantsAdded={addParticipant}
onFinish={goToNextStep}
iouType={iouType}
iouRequestType={iouRequestType}
didScreenTransitionEnd={didScreenTransitionEnd}
/>
)}
</StepScreenWrapper>
);
}
Expand Down

0 comments on commit caf91ae

Please sign in to comment.