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

RTL Text gets renderd properly #29434

Merged
Show file tree
Hide file tree
Changes from 4 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
2 changes: 1 addition & 1 deletion src/components/Composer/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ function Composer({
placeholderTextColor={themeColors.placeholderText}
ref={(el) => (textInput.current = el)}
selection={selection}
style={inputStyleMemo}
style={(Browser.isMobileSafari() || Browser.isSafari()) ? [inputStyleMemo, styles.rtlTextRenderForSafari] : [inputStyleMemo]}
HardikChoudhary24 marked this conversation as resolved.
Show resolved Hide resolved
value={value}
forwardedRef={forwardedRef}
defaultValue={defaultValue}
Expand Down
10 changes: 9 additions & 1 deletion src/libs/convertToLTR/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
import CONST from '../../CONST';
import ConvertToLTR from './types';

const convertToLTR: ConvertToLTR = (text) => text;
const convertToLTR: ConvertToLTR = (text) => {
HardikChoudhary24 marked this conversation as resolved.
Show resolved Hide resolved
// Check if the text already starts with the LTR marker (if so, return as is).
if (text.startsWith(CONST.UNICODE.LTR)) {
return text;
}

// // Add the LTR marker to the beginning of the text.
HardikChoudhary24 marked this conversation as resolved.
Show resolved Hide resolved
return `${CONST.UNICODE.LTR}${text}`;
};
export default convertToLTR;
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, {useEffect, useCallback, useState, useRef, useMemo, useImperativeHandle} from 'react';
import {View, NativeModules, findNodeHandle} from 'react-native';
import {View, NativeModules, findNodeHandle, Platform} from 'react-native';
import {withOnyx} from 'react-native-onyx';
import _ from 'underscore';
import lodashGet from 'lodash/get';
Expand Down Expand Up @@ -34,6 +34,7 @@ import withKeyboardState from '../../../../components/withKeyboardState';
import {propTypes, defaultProps} from './composerWithSuggestionsProps';
import focusWithDelay from '../../../../libs/focusWithDelay';
import useDebounce from '../../../../hooks/useDebounce';
import convertToLTR from '../../../../libs/convertToLTR';
import * as InputFocus from '../../../../libs/actions/InputFocus';

const {RNTextInputReset} = NativeModules;
Expand Down Expand Up @@ -221,7 +222,7 @@ function ComposerWithSuggestions({
}
emojisPresentBefore.current = emojis;
setIsCommentEmpty(!!newComment.match(/^(\s)*$/));
setValue(newComment);
setValue(Platform.OS === 'android' ?newComment : convertToLTR(newComment));
HardikChoudhary24 marked this conversation as resolved.
Show resolved Hide resolved
if (commentValue !== newComment) {
// Ensure emoji suggestions are hidden even when the selection is not changed (so calculateEmojiSuggestion would not be called).
if (suggestionsRef.current) {
Expand Down
5 changes: 5 additions & 0 deletions src/styles/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,11 @@ const styles = (theme: ThemeDefault) =>
alignItems: 'center',
},

rtlTextRenderForSafari: {
textAlign: 'left',
...writingDirection.ltr,
},

emojiSuggestionsEmoji: {
fontSize: variables.fontSizeMedium,
width: 51,
Expand Down
Loading