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

RoomNameInput - Migrate setNativeProps to state #11037

Merged
merged 3 commits into from
Sep 22, 2022
Merged
Show file tree
Hide file tree
Changes from 2 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
8 changes: 4 additions & 4 deletions src/components/RoomNameInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ const propTypes = {
/** Callback to execute when the text input is modified correctly */
onChangeText: PropTypes.func,

/** Initial room name to show in input field. This should include the '#' already prefixed to the name */
initialValue: PropTypes.string,
/** Room name to show in input field. This should include the '#' already prefixed to the name */
value: PropTypes.string,

/** Whether we should show the input as disabled */
disabled: PropTypes.bool,
Expand Down Expand Up @@ -50,7 +50,7 @@ const propTypes = {

const defaultProps = {
onChangeText: () => {},
initialValue: '',
value: '',
disabled: false,
errorText: '',
...fullPolicyDefaultProps,
Expand Down Expand Up @@ -101,7 +101,7 @@ class RoomNameInput extends Component {
prefixCharacter={CONST.POLICY.ROOM_PREFIX}
placeholder={this.props.translate('newRoomPage.social')}
onChange={this.setModifiedRoomName}
defaultValue={this.props.initialValue.substring(1)} // Since the room name always starts with a prefix, we omit the first character to avoid displaying it twice.
value={this.props.value.substring(1)} // Since the room name always starts with a prefix, we omit the first character to avoid displaying it twice.
errorText={this.props.errorText}
autoCapitalize="none"
/>
Expand Down
7 changes: 1 addition & 6 deletions src/pages/ReportSettingsPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,6 @@ class ReportSettingsPage extends Component {
*/
resetToPreviousName() {
this.setState({newRoomName: this.props.report.reportName});

// Reset the input's value back to the previously saved report name
if (this.roomNameInputRef) {
this.roomNameInputRef.setNativeProps({text: this.props.report.reportName.replace(CONST.POLICY.ROOM_PREFIX, '')});
}
Report.clearPolicyRoomNameErrors(this.props.report.reportID);
}

Expand Down Expand Up @@ -229,7 +224,7 @@ class ReportSettingsPage extends Component {
: (
<RoomNameInput
ref={el => this.roomNameInputRef = el}
initialValue={this.state.newRoomName}
value={this.state.newRoomName}
policyID={linkedWorkspace && linkedWorkspace.id}
errorText={this.state.errors.newRoomName}
onChangeText={newRoomName => this.clearErrorAndSetValue('newRoomName', newRoomName)}
Expand Down