-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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: Edit composer moves focus to main composer after press LHN menu item #24481
Merged
Merged
Changes from 1 commit
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
994fd6f
fix: 23898
tienifr f5b834f
Merge branch 'main' of https://github.com/tienifr/App into fix/23898
tienifr 9480a6c
add comment and remove logs
tienifr 39b3902
add null check
tienifr d3ec5e4
clear callback when exit draft mode
tienifr c7fb2ff
Merge branch 'main' into fix/23898
tienifr 76c3710
clear callback on unmount
tienifr bc9b0d6
Merge branch 'main' into fix/23898
tienifr 3a64c6e
move to existing cleanup func
tienifr 56ceb26
remove redundant cleanup
tienifr 0f744e4
do not re-focus on unmount
tienifr fafeeaf
remove ref
tienifr 9b8f563
remove redundant check
tienifr a623c7d
modify comment
tienifr 9add8d1
clear focus callback only in case of edit compose
tienifr 9005a8a
only clear in case of edit composer
tienifr File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
move to existing cleanup func
- Loading branch information
commit 3a64c6ecc6ca866747c0e4ab66246788982d6729
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,8 +18,8 @@ import Text from '../Text'; | |
import isEnterWhileComposition from '../../libs/KeyboardShortcut/isEnterWhileComposition'; | ||
import CONST from '../../CONST'; | ||
import withNavigation from '../withNavigation'; | ||
import ReportActionComposeFocusManager from "../../libs/ReportActionComposeFocusManager"; | ||
import willBlurTextInputOnTapOutside from "../../libs/willBlurTextInputOnTapOutside"; | ||
import ReportActionComposeFocusManager from '../../libs/ReportActionComposeFocusManager'; | ||
import willBlurTextInputOnTapOutside from '../../libs/willBlurTextInputOnTapOutside'; | ||
|
||
const propTypes = { | ||
/** Maximum number of lines in the text input */ | ||
|
@@ -161,7 +161,7 @@ function Composer({ | |
}) { | ||
const textRef = useRef(null); | ||
const textInput = useRef(null); | ||
const willBlurTextInputOnTapOutsideRef= useRef(); | ||
const willBlurTextInputOnTapOutsideRef = useRef(); | ||
willBlurTextInputOnTapOutsideRef.current = willBlurTextInputOnTapOutside(); | ||
const initialValue = defaultValue ? `${defaultValue}` : `${value || ''}`; | ||
const [numberOfLines, setNumberOfLines] = useState(numberOfLinesProp); | ||
|
@@ -358,10 +358,13 @@ function Composer({ | |
updateNumberOfLines(); | ||
}, [updateNumberOfLines]); | ||
|
||
useEffect(() => () => { | ||
ReportActionComposeFocusManager.clear(); | ||
ReportActionComposeFocusManager.focus(); | ||
}, []); | ||
useEffect( | ||
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. Why is this still here? 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. My fault!! |
||
() => () => { | ||
ReportActionComposeFocusManager.clear(); | ||
ReportActionComposeFocusManager.focus(); | ||
}, | ||
[], | ||
); | ||
|
||
useEffect(() => { | ||
// we need to handle listeners on navigation focus/blur as Composer is not unmounting | ||
|
@@ -379,6 +382,8 @@ function Composer({ | |
} | ||
|
||
return () => { | ||
ReportActionComposeFocusManager.clear(); | ||
ReportActionComposeFocusManager.focus(); | ||
unsubscribeFocus(); | ||
unsubscribeBlur(); | ||
document.removeEventListener('paste', handlePaste); | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Just out of curiosity, why did you change this to a ref?
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.
I think it's better to just directly call the function instead of creating the ref, right? I've updated that.
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.
Yeah we do it that way in reportActionCompose.
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.
But do we even need it allall seeing as we are only adding this to
composer
on web, andwillBlurTextInputOnTapOutside
only returns true on web. Correct me if I'm wrong but won't it return true 100% of the time here?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.
Agree! I was trying to replicate the conditions from ReportActionCompose without noticing that.