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: App loses focus on money request participant selector's text input #27294

Merged
merged 2 commits into from
Sep 13, 2023
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ function MoneyRequestParticipantsPage(props) {
const prevMoneyRequestId = useRef(props.iou.id);
const iouType = useRef(lodashGet(props.route, 'params.iouType', ''));
const reportID = useRef(lodashGet(props.route, 'params.reportID', ''));
const optionsSelectorRef = useRef();
const isDistanceRequest = MoneyRequestUtils.isDistanceRequest(iouType.current, props.selectedTab);

const navigateToNextStep = () => {
Expand Down Expand Up @@ -88,6 +89,7 @@ function MoneyRequestParticipantsPage(props) {
<ScreenWrapper
includeSafeAreaPaddingBottom={false}
shouldEnableMaxHeight={DeviceCapabilities.canUseTouchScreen()}
onEntryTransitionEnd={() => optionsSelectorRef.current && optionsSelectorRef.current.focus()}
>
{({safeAreaPaddingBottomStyle}) => (
<View style={styles.flex1}>
Expand All @@ -104,6 +106,7 @@ function MoneyRequestParticipantsPage(props) {
/>
) : (
<MoneyRequestParticipantsSelector
ref={(el) => (optionsSelectorRef.current = el)}
onStepComplete={navigateToNextStep}
onAddParticipants={IOU.setMoneyRequestParticipants}
safeAreaPaddingBottomStyle={safeAreaPaddingBottomStyle}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,15 @@ import compose from '../../../../libs/compose';
import CONST from '../../../../CONST';
import personalDetailsPropType from '../../../personalDetailsPropType';
import reportPropTypes from '../../../reportPropTypes';
import refPropTypes from '../../../../components/refPropTypes';

const propTypes = {
/** Beta features list */
betas: PropTypes.arrayOf(PropTypes.string),

/** A ref to forward to options selector's text input */
forwardedRef: refPropTypes,

/** Callback to inform parent modal of success */
onStepComplete: PropTypes.func.isRequired,

Expand All @@ -41,6 +45,7 @@ const propTypes = {
};

const defaultProps = {
forwardedRef: undefined,
safeAreaPaddingBottomStyle: {},
personalDetails: {},
reports: {},
Expand Down Expand Up @@ -161,6 +166,8 @@ class MoneyRequestParticipantsSelector extends Component {

return (
<OptionsSelector
ref={this.props.forwardedRef}
autoFocus={false}
sections={this.getSections()}
value={this.state.searchTerm}
onSelectRow={this.addSingleParticipant}
Expand Down Expand Up @@ -191,4 +198,12 @@ export default compose(
key: ONYXKEYS.BETAS,
},
}),
)(MoneyRequestParticipantsSelector);
)(
React.forwardRef((props, ref) => (
<MoneyRequestParticipantsSelector
/* eslint-disable-next-line react/jsx-props-no-spreading */
{...props}
forwardedRef={ref}
/>
)),
);