-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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 #23994 from ntdiary/fix-13922
fix keyboard flashing while clicking "Add attachment"
- Loading branch information
Showing
11 changed files
with
146 additions
and
62 deletions.
There are no files selected for viewing
18 changes: 18 additions & 0 deletions
18
patches/react-native+0.72.3+004+ModalKeyboardFlashing.patch
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,18 @@ | ||
diff --git a/node_modules/react-native/React/Views/RCTModalHostViewManager.m b/node_modules/react-native/React/Views/RCTModalHostViewManager.m | ||
index 4b9f9ad..b72984c 100644 | ||
--- a/node_modules/react-native/React/Views/RCTModalHostViewManager.m | ||
+++ b/node_modules/react-native/React/Views/RCTModalHostViewManager.m | ||
@@ -79,6 +79,13 @@ RCT_EXPORT_MODULE() | ||
if (self->_presentationBlock) { | ||
self->_presentationBlock([modalHostView reactViewController], viewController, animated, completionBlock); | ||
} else { | ||
+ // In our App, If an input is blurred and a modal is opened, the rootView will become the firstResponder, which | ||
+ // will cause system to retain a wrong keyboard state, and then the keyboard to flicker when the modal is closed. | ||
+ // We first resign the rootView to avoid this problem. | ||
+ UIWindow *window = RCTKeyWindow(); | ||
+ if (window && window.rootViewController && [window.rootViewController.view isFirstResponder]) { | ||
+ [window.rootViewController.view resignFirstResponder]; | ||
+ } | ||
[[modalHostView reactViewController] presentViewController:viewController | ||
animated:animated | ||
completion:completionBlock]; |
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
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
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,23 @@ | ||
let isReadyToFocusPromise = Promise.resolve(); | ||
let resolveIsReadyToFocus; | ||
|
||
function resetReadyToFocus() { | ||
isReadyToFocusPromise = new Promise((resolve) => { | ||
resolveIsReadyToFocus = resolve; | ||
}); | ||
} | ||
function setReadyToFocus() { | ||
if (!resolveIsReadyToFocus) { | ||
return; | ||
} | ||
resolveIsReadyToFocus(); | ||
} | ||
function isReadyToFocus() { | ||
return isReadyToFocusPromise; | ||
} | ||
|
||
export default { | ||
resetReadyToFocus, | ||
setReadyToFocus, | ||
isReadyToFocus, | ||
}; |
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,35 @@ | ||
import {InteractionManager} from 'react-native'; | ||
import ComposerFocusManager from './ComposerFocusManager'; | ||
|
||
/** | ||
* Create a function that focuses a text input. | ||
* @param {Object} textInput the text input to focus | ||
* @returns {Function} a function that focuses the text input with a configurable delay | ||
*/ | ||
function focusWithDelay(textInput) { | ||
/** | ||
* Focus the text input | ||
* @param {Boolean} [shouldDelay=false] Impose delay before focusing the text input | ||
*/ | ||
return (shouldDelay = false) => { | ||
// There could be other animations running while we trigger manual focus. | ||
// This prevents focus from making those animations janky. | ||
InteractionManager.runAfterInteractions(() => { | ||
if (!textInput) { | ||
return; | ||
} | ||
if (!shouldDelay) { | ||
textInput.focus(); | ||
return; | ||
} | ||
ComposerFocusManager.isReadyToFocus().then(() => { | ||
if (!textInput) { | ||
return; | ||
} | ||
textInput.focus(); | ||
}); | ||
}); | ||
}; | ||
} | ||
|
||
export default focusWithDelay; |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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