-
Notifications
You must be signed in to change notification settings - Fork 3k
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
fix: 10731 Focus composer without showing keyboard when users go to chats #32711
Changes from all commits
d8eb426
07fdad0
a5f99b7
f764d66
f6e2e28
4b19bdf
7e930b8
96e924d
8edc49a
5dc6922
b6647b4
432e67e
e6bfa42
eb79042
aec542a
802f37d
d036e24
dd50857
b008b05
025fa15
c48bb63
726154d
5e13e27
69bc468
c037b05
3e60d1e
7ba9d60
958e9df
ca23e24
c59d44f
fb798c0
fcac742
18055ae
381fdff
e08d442
2282bf6
1245315
33e093e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,7 +29,6 @@ import useStyleUtils from '@hooks/useStyleUtils'; | |
import useTheme from '@hooks/useTheme'; | ||
import useThemeStyles from '@hooks/useThemeStyles'; | ||
import * as Browser from '@libs/Browser'; | ||
import canFocusInputOnScreenFocus from '@libs/canFocusInputOnScreenFocus'; | ||
import {forceClearInput} from '@libs/ComponentUtils'; | ||
import * as ComposerUtils from '@libs/ComposerUtils'; | ||
import convertToLTRForComposer from '@libs/convertToLTRForComposer'; | ||
|
@@ -40,7 +39,6 @@ import getPlatform from '@libs/getPlatform'; | |
import * as KeyDownListener from '@libs/KeyboardShortcut/KeyDownPressListener'; | ||
import Parser from '@libs/Parser'; | ||
import ReportActionComposeFocusManager from '@libs/ReportActionComposeFocusManager'; | ||
import * as ReportActionsUtils from '@libs/ReportActionsUtils'; | ||
import * as ReportUtils from '@libs/ReportUtils'; | ||
import updateMultilineInputRange from '@libs/updateMultilineInputRange'; | ||
import willBlurTextInputOnTapOutsideFunc from '@libs/willBlurTextInputOnTapOutside'; | ||
|
@@ -66,9 +64,6 @@ type SyncSelection = { | |
type NewlyAddedChars = {startIndex: number; endIndex: number; diff: string}; | ||
|
||
type ComposerWithSuggestionsOnyxProps = { | ||
/** The parent report actions for the report */ | ||
parentReportActions: OnyxEntry<OnyxTypes.ReportActions>; | ||
|
||
/** The modal state */ | ||
modal: OnyxEntry<OnyxTypes.Modal>; | ||
|
||
|
@@ -150,22 +145,12 @@ type ComposerWithSuggestionsProps = ComposerWithSuggestionsOnyxProps & | |
/** Whether the edit is focused */ | ||
editFocused: boolean; | ||
|
||
/** Wheater chat is empty */ | ||
isEmptyChat?: boolean; | ||
|
||
/** The last report action */ | ||
lastReportAction?: OnyxEntry<OnyxTypes.ReportAction>; | ||
|
||
/** Whether to include chronos */ | ||
includeChronos?: boolean; | ||
|
||
/** The parent report action ID */ | ||
parentReportActionID?: string; | ||
|
||
/** The parent report ID */ | ||
// eslint-disable-next-line react/no-unused-prop-types -- its used in the withOnyx HOC | ||
parentReportID: string | undefined; | ||
|
||
/** Whether report is from group policy */ | ||
isGroupPolicyReport: boolean; | ||
|
||
|
@@ -211,10 +196,6 @@ const debouncedBroadcastUserIsTyping = lodashDebounce( | |
|
||
const willBlurTextInputOnTapOutside = willBlurTextInputOnTapOutsideFunc(); | ||
|
||
// We want consistent auto focus behavior on input between native and mWeb so we have some auto focus management code that will | ||
// prevent auto focus on existing chat for mobile device | ||
const shouldFocusInputOnScreenFocus = canFocusInputOnScreenFocus(); | ||
|
||
/** | ||
* This component holds the value and selection state. | ||
* If a component really needs access to these state values it should be put here. | ||
|
@@ -226,14 +207,11 @@ function ComposerWithSuggestions( | |
// Onyx | ||
modal, | ||
preferredSkinTone = CONST.EMOJI_DEFAULT_SKIN_TONE, | ||
parentReportActions, | ||
|
||
// Props: Report | ||
reportID, | ||
includeChronos, | ||
isEmptyChat, | ||
lastReportAction, | ||
parentReportActionID, | ||
isGroupPolicyReport, | ||
policyID, | ||
|
||
|
@@ -298,17 +276,13 @@ function ComposerWithSuggestions( | |
const {shouldUseNarrowLayout} = useResponsiveLayout(); | ||
const maxComposerLines = shouldUseNarrowLayout ? CONST.COMPOSER.MAX_LINES_SMALL_SCREEN : CONST.COMPOSER.MAX_LINES; | ||
|
||
const parentReportAction = parentReportActions?.[parentReportActionID ?? '-1']; | ||
const shouldAutoFocus = | ||
!modal?.isVisible && | ||
Modal.areAllModalsHidden() && | ||
isFocused && | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @christianwen Why do we remove There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thank you, I think we should add isFocused again, when the chat is not focused, we shouldn't trigger focus input |
||
(shouldFocusInputOnScreenFocus || (isEmptyChat && !ReportActionsUtils.isTransactionThread(parentReportAction))) && | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @rojiphil This PR was reverted There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh! Thanks for pointing this out. Didn't notice this. Let me dig a little deeper. |
||
shouldShowComposeInput; | ||
const shouldAutoFocus = !modal?.isVisible && shouldShowComposeInput && Modal.areAllModalsHidden() && isFocused; | ||
|
||
const valueRef = useRef(value); | ||
valueRef.current = value; | ||
|
||
const [showSoftInputOnFocus, setShowSoftInputOnFocus] = useState(false); | ||
|
||
const [selection, setSelection] = useState<TextSelection>(() => ({start: value.length, end: value.length, positionX: 0, positionY: 0})); | ||
|
||
const [composerHeight, setComposerHeight] = useState(0); | ||
|
@@ -798,6 +772,19 @@ function ComposerWithSuggestions( | |
shouldCalculateCaretPosition | ||
onLayout={onLayout} | ||
onScroll={hideSuggestionMenu} | ||
showSoftInputOnFocus={showSoftInputOnFocus} | ||
onTouchStart={() => { | ||
if (showSoftInputOnFocus) { | ||
return; | ||
} | ||
if (Browser.isMobileSafari()) { | ||
setTimeout(() => { | ||
setShowSoftInputOnFocus(true); | ||
}, CONST.ANIMATED_TRANSITION); | ||
return; | ||
} | ||
setShowSoftInputOnFocus(true); | ||
}} | ||
shouldContainScroll={Browser.isMobileSafari()} | ||
isGroupPolicyReport={isGroupPolicyReport} | ||
/> | ||
|
@@ -848,11 +835,6 @@ export default withOnyx<ComposerWithSuggestionsProps & RefAttributes<ComposerRef | |
editFocused: { | ||
key: ONYXKEYS.INPUT_FOCUSED, | ||
}, | ||
parentReportActions: { | ||
key: ({parentReportID}) => `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${parentReportID}`, | ||
canEvict: false, | ||
initWithStoredValues: false, | ||
}, | ||
})(memo(ComposerWithSuggestionsWithRef)); | ||
|
||
export type {ComposerWithSuggestionsProps, ComposerRef}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why this was deleted?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same question.
After rechecking. This is added #18699 and now we change the expectation. So this should be removed to align with new expect