Find a real TextInput instead of its parent when contextMenuHidden prop is specified.
๐ก Motivation and Context
If contextMenuHidden is specified then UIResponder.current returns the parent of the actual TextInput. In case of paper element will be:
RCTSinglelineTextInputView (single line)
RCTMultilineTextInputView (multi line)
On fabric it'll always be:
RCTTextInputComponentView
Casting view to one of the following classes can be expensive in terms of supporting RN versions - RN team can change class names/files and it will not be considered as a breaking change (because it's not public API), but we'll need to make conditional imports/do conditional casting etc.
But in fact we just need to check that current responder belongs to these classes and if yes then take the first children (with casting to UIView). That's what I did in this PR.
I think this PR shouldn't bring any breaking changes, since we just handle one small corner case.
Also we had to re-work KeyboardController.dismiss functionality - we need to use our implementation for detecting first responder, so I had to add @objc annotation to use my extension in ObjC code.
๐ Description
Find a real
TextInput
instead of its parent whencontextMenuHidden
prop is specified.๐ก Motivation and Context
If
contextMenuHidden
is specified thenUIResponder.current
returns the parent of the actualTextInput
. In case of paper element will be:RCTSinglelineTextInputView
(single line)RCTMultilineTextInputView
(multi line)On fabric it'll always be:
RCTTextInputComponentView
Casting view to one of the following classes can be expensive in terms of supporting RN versions - RN team can change class names/files and it will not be considered as a breaking change (because it's not public API), but we'll need to make conditional imports/do conditional casting etc.
But in fact we just need to check that current responder belongs to these classes and if yes then take the first children (with casting to
UIView
). That's what I did in this PR.I think this PR shouldn't bring any breaking changes, since we just handle one small corner case.
Also we had to re-work
KeyboardController.dismiss
functionality - we need to use our implementation for detecting first responder, so I had to add@objc
annotation to use my extension in ObjC code.Closes https://github.com/kirillzyusko/react-native-keyboard-controller/issues/496
๐ข Changelog
iOS
๐ค How Has This Been Tested?
Tested on CI + updated example app to be sure we verify newly added code.
๐ธ Screenshots (if appropriate):
๐ Checklist