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

[IS-3186] Fixed cursor position issue on Android #3374

Merged
merged 6 commits into from
Jun 8, 2021
Merged
Changes from 1 commit
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
17 changes: 15 additions & 2 deletions src/pages/home/report/ReportActionCompose.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ import Navigation from '../../../libs/Navigation/Navigation';
import ROUTES from '../../../ROUTES';
import ReportActionPropTypes from './ReportActionPropTypes';
import {canEditReportAction} from '../../../libs/reportUtils';
import getPlatform from '../../../libs/getPlatform/index';

const propTypes = {
/** A method to call when the form is submitted */
Expand Down Expand Up @@ -124,6 +125,7 @@ class ReportActionCompose extends React.Component {
this.focusEmojiSearchInput = this.focusEmojiSearchInput.bind(this);
this.measureEmojiPopoverAnchorPosition = this.measureEmojiPopoverAnchorPosition.bind(this);
this.onSelectionChange = this.onSelectionChange.bind(this);
this.updateSelectionOnAndroid = this.updateSelectionOnAndroid.bind(this);
this.emojiPopoverAnchor = null;
this.emojiSearchInput = null;

Expand Down Expand Up @@ -166,7 +168,10 @@ class ReportActionCompose extends React.Component {
}

onSelectionChange(e) {
this.setState({selection: e.nativeEvent.selection});
const selection = e.nativeEvent.selection;
this.setState({selection}, () => {
this.updateSelectionOnAndroid(this.comment, selection);
});
}

/**
Expand Down Expand Up @@ -196,6 +201,12 @@ class ReportActionCompose extends React.Component {
this.setState({isMenuVisible});
}

updateSelectionOnAndroid(text, selection) {
if (getPlatform() === 'android') {
this.textInput.setNativeProps({text, selection});
}
}

aliabbasmalik8 marked this conversation as resolved.
Show resolved Hide resolved
/**
* Focus the composer text input
*/
Expand Down Expand Up @@ -313,7 +324,9 @@ class ReportActionCompose extends React.Component {
start: selection.start + emoji.length,
end: selection.start + emoji.length,
};
this.setState({selection: updatedSelection});
this.setState({selection: updatedSelection}, () => {
this.updateSelectionOnAndroid(this.textInput.value, updatedSelection);
});
this.setIsFocused(true);
this.focus();
this.updateComment(this.textInput.value);
Expand Down