-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #37666 from MrRefactor/proposal/28563
Fix problem with cursor jumping back to start when adding an emoji in edit mode
- Loading branch information
Showing
11 changed files
with
93 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import type {TextInput} from 'react-native'; | ||
import shouldSetSelectionRange from '@libs/shouldSetSelectionRange'; | ||
import type {InputType, Selection} from './types'; | ||
|
||
const setSelectionRange = shouldSetSelectionRange(); | ||
|
||
const setTextInputSelection = (textInput: InputType, forcedSelectionRange: Selection) => { | ||
if (setSelectionRange) { | ||
(textInput as HTMLTextAreaElement).setSelectionRange(forcedSelectionRange.start, forcedSelectionRange.end); | ||
} else { | ||
(textInput as TextInput).setSelection(forcedSelectionRange.start, forcedSelectionRange.end); | ||
} | ||
}; | ||
|
||
export default setTextInputSelection; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import type {TextInput} from 'react-native'; | ||
|
||
type Selection = { | ||
start: number; | ||
end: number; | ||
}; | ||
|
||
type FocusComposerWithDelay = (shouldDelay?: boolean, forcedSelectionRange?: Selection) => void; | ||
|
||
type InputType = TextInput | HTMLTextAreaElement; | ||
|
||
export type {Selection, FocusComposerWithDelay, InputType}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import type ShouldSetSelectionRange from './types'; | ||
|
||
const shouldSetSelectionRange: ShouldSetSelectionRange = () => false; | ||
|
||
export default shouldSetSelectionRange; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import type ShouldSetSelectionRange from './types'; | ||
|
||
const shouldSetSelectionRange: ShouldSetSelectionRange = () => true; | ||
|
||
export default shouldSetSelectionRange; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
type ShouldSetSelectionRange = () => boolean; | ||
|
||
export default ShouldSetSelectionRange; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
src/pages/home/report/shouldUseEmojiPickerSelection/index.android.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import type ShouldUseEmojiPickerSelection from './types'; | ||
|
||
const shouldUseEmojiPickerSelection: ShouldUseEmojiPickerSelection = () => true; | ||
|
||
export default shouldUseEmojiPickerSelection; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import type ShouldUseEmojiPickerSelection from './types'; | ||
|
||
const shouldUseEmojiPickerSelection: ShouldUseEmojiPickerSelection = () => false; | ||
|
||
export default shouldUseEmojiPickerSelection; |
8 changes: 8 additions & 0 deletions
8
src/pages/home/report/shouldUseEmojiPickerSelection/index.website.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import * as Browser from '@libs/Browser'; | ||
import type ShouldUseEmojiPickerSelection from './types'; | ||
|
||
const isMobileChrome = Browser.isMobileChrome(); | ||
|
||
const shouldUseEmojiPickerSelection: ShouldUseEmojiPickerSelection = () => isMobileChrome; | ||
|
||
export default shouldUseEmojiPickerSelection; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
type ShouldUseEmojiPickerSelection = () => boolean; | ||
|
||
export default ShouldUseEmojiPickerSelection; |