kirillzyusko / react-native-keyboard-controller

Keyboard manager which works in identical way on both iOS and Android
https://kirillzyusko.github.io/react-native-keyboard-controller/
MIT License
1.54k stars 61 forks source link

fix: handle `contextMenuHidden` prop #498

Closed kirillzyusko closed 1 month ago

kirillzyusko commented 1 month ago

๐Ÿ“œ Description

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:

On fabric it'll always be:

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

github-actions[bot] commented 1 month ago

๐Ÿ“Š Package size report

Current size Target Size Difference
145278 bytes 145110 bytes 168 bytes ๐Ÿ“ˆ