Skip to content

Commit

Permalink
input of '[' and other special characters fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
HardikChoudhary24 committed Oct 29, 2023
1 parent e99c297 commit 7bbc841
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/libs/convertToLTRForComposer/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import CONST from '@src/CONST';
import CONST from '../../CONST';

Check warning on line 1 in src/libs/convertToLTRForComposer/index.ts

View workflow job for this annotation

GitHub Actions / lint

Unexpected parent import '../../CONST'. Use '@src/CONST' instead
import ConvertToLTRForComposer from './types';

function hasRTLCharacters(text: string): boolean {
Expand All @@ -9,10 +9,11 @@ function hasRTLCharacters(text: string): boolean {

// Converts a given text to ensure it starts with the LTR (Left-to-Right) marker.
const convertToLTRForComposer: ConvertToLTRForComposer = (text) => {
// Ensure that the text starts with RTL characters if not we return the same text to avoid concatination with special character at the start which leads to unexpected behaviour for Emoji/Mention suggestions.
// Ensure that the text starts with RTL characters if not we return the same text to avoid concatination with special
// character at the start which leads to unexpected behaviour for Emoji/Mention suggestions.
if (!hasRTLCharacters(text)) {
// If text is empty string return empty string to avoid an empty draft due to special character.
if (text === '' || CONST.UNICODE.LTR.match(text)) {
if (text === '' || text.startsWith(CONST.UNICODE.LTR)) {
return '';
}
return text;
Expand Down

0 comments on commit 7bbc841

Please sign in to comment.