Skip to content

Commit

Permalink
RoomNameInput cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
kowczarz committed Dec 12, 2023
1 parent abbca90 commit f0ac1bd
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
5 changes: 3 additions & 2 deletions src/components/RoomNameInput/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@ import React, {useState} from 'react';
import _ from 'underscore';
import TextInput from '@components/TextInput';
import useLocalize from '@hooks/useLocalize';
import getOperatingSystem from '@libs/getOperatingSystem';
import * as RoomNameInputUtils from '@libs/RoomNameInputUtils';
import CONST from '@src/CONST';
import * as roomNameInputPropTypes from './roomNameInputPropTypes';

function RoomNameInput({isFocused, autoFocus, disabled, errorText, forwardedRef, value, onBlur, onChangeText, onInputChange, shouldDelayFocus, ...restProps}) {
function RoomNameInput({isFocused, autoFocus, disabled, errorText, forwardedRef, value, onBlur, onChangeText, onInputChange, shouldDelayFocus, prefixCharacter, ...restProps}) {
const {translate} = useLocalize();

const [selection, setSelection] = useState();
Expand Down Expand Up @@ -42,6 +41,7 @@ function RoomNameInput({isFocused, autoFocus, disabled, errorText, forwardedRef,
setSelection(newSelection);
}
};

return (
<TextInput
// eslint-disable-next-line react/jsx-props-no-spreading
Expand All @@ -51,6 +51,7 @@ function RoomNameInput({isFocused, autoFocus, disabled, errorText, forwardedRef,
label={translate('newRoomPage.roomName')}
accessibilityLabel={translate('newRoomPage.roomName')}
role={CONST.ACCESSIBILITY_ROLE.TEXT}
prefixCharacter={prefixCharacter}
placeholder={translate('newRoomPage.social')}
onChange={setModifiedRoomName}
value={value.substring(1)} // Since the room name always starts with a prefix, we omit the first character to avoid displaying it twice.
Expand Down
5 changes: 5 additions & 0 deletions src/components/RoomNameInput/roomNameInputPropTypes.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import PropTypes from 'prop-types';
import CONST from '@src/CONST';

const propTypes = {
/** Callback to execute when the text input is modified correctly */
Expand Down Expand Up @@ -30,6 +31,9 @@ const propTypes = {

/** Whether navigation is focused */
isFocused: PropTypes.bool.isRequired,

/** Prefix character */
prefixCharacter: PropTypes.string,
};

const defaultProps = {
Expand All @@ -43,6 +47,7 @@ const defaultProps = {
onBlur: () => {},
autoFocus: false,
shouldDelayFocus: false,
prefixCharacter: CONST.POLICY.ROOM_PREFIX,
};

export {propTypes, defaultProps};
2 changes: 0 additions & 2 deletions src/pages/settings/Report/RoomNamePage.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import compose from '@libs/compose';
import * as ErrorUtils from '@libs/ErrorUtils';
import Navigation from '@libs/Navigation/Navigation';
import * as ReportUtils from '@libs/ReportUtils';
import * as RoomNameInputUtils from '@libs/RoomNameInputUtils';
import * as ValidationUtils from '@libs/ValidationUtils';
import withReportOrNotFound from '@pages/home/report/withReportOrNotFound';
import reportPropTypes from '@pages/reportPropTypes';
Expand Down Expand Up @@ -103,7 +102,6 @@ function RoomNamePage({policy, report, reports, translate}) {
inputID="roomName"
defaultValue={report.reportName}
isFocused={isFocused}
prefixCharacter={CONST.POLICY.ROOM_PREFIX}
/>
</View>
</FormProvider>
Expand Down
1 change: 0 additions & 1 deletion src/pages/workspace/WorkspaceNewRoomPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,6 @@ function WorkspaceNewRoomPage(props) {
isFocused={props.isFocused}
shouldDelayFocus
autoFocus
prefixCharacter={CONST.POLICY.ROOM_PREFIX}
/>
</View>
<View style={styles.mb5}>
Expand Down

0 comments on commit f0ac1bd

Please sign in to comment.