Skip to content
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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: not detectable keyboard view on iOS #471

Merged
merged 2 commits into from
Jun 14, 2024

Conversation

kirillzyusko
Copy link
Owner

@kirillzyusko kirillzyusko commented Jun 13, 2024

馃摐 Description

Handle corner case when keyboard view is not detectable on iOS.

馃挕 Motivation and Context

Sometimes app may have more than one UITextEffectsWindow and nested UIInputSetContainerView may not have a children (as on a screenshot):

image

In this case our previous code would return nil and full library functionality would be broken. From a screenshot above it's clear, that we should continue our search.

So to fix the problem I removed one break signal (loop over windows). Thus if we encounter empty UIInputSetContainerView we will continue search and will go to the next window (which will return a correct reference to the keyboard view).

Additionally I added return statement when we found a view (before 3 break statements served for this purpose, but since I removed one - the order is slightly broken, so to keep better backward compatibility and don't execute additional cycles if view was found - I used return statement there).

See the context when we may have more than one UITextEffectsWindow in #338 (comment)

馃摙 Changelog

iOS

  • removed break inside iteration over windows
  • added return to exit from for loops immediately
  • refactored code and removed variable creation

馃 How Has This Been Tested?

Tested on iPhone 15 Pro (iOS 17.5).

馃摳 Screenshots (if appropriate):

Before After
Simulator.Screen.Recording.-.iPhone.15.Pro.-.2024-06-14.at.10.23.01.mp4
Simulator.Screen.Recording.-.iPhone.15.Pro.-.2024-06-14.at.10.22.09.mp4

馃摑 Checklist

  • CI successfully passed
  • I added new mocks and corresponding unit-tests if library API was changed

@kirillzyusko kirillzyusko added 馃悰 bug Something isn't working 馃崕 iOS iOS specific labels Jun 13, 2024
@kirillzyusko kirillzyusko self-assigned this Jun 13, 2024
Copy link
Contributor

github-actions bot commented Jun 13, 2024

馃搳 Package size report

Current size Target Size Difference
144004 bytes 144033 bytes -29 bytes 馃搲

@kirillzyusko kirillzyusko force-pushed the fix/keyboard-view-is-not-detectable branch from 9e09296 to 7053e1f Compare June 13, 2024 17:00
@kirillzyusko kirillzyusko marked this pull request as ready for review June 14, 2024 08:31
@kirillzyusko kirillzyusko merged commit 950d3bc into main Jun 14, 2024
12 checks passed
@kirillzyusko kirillzyusko deleted the fix/keyboard-view-is-not-detectable branch June 14, 2024 08:31
kirillzyusko added a commit that referenced this pull request Jun 14, 2024
## 馃摐 Description

Ignore non visible keyboard in `KeyboardView.find()` method.

## 馃挕 Motivation and Context

Sometimes we may have two keyboards:


![image](https://github.com/kirillzyusko/react-native-keyboard-controller/assets/22820318/52456847-f1fd-4cd6-a21a-81a5afd8d6c8)

And the current algorithm for a search returns an invalid keyboard (not
a one that is actually shown on the screen):


![image](https://github.com/kirillzyusko/react-native-keyboard-controller/assets/22820318/fc22c83d-95c5-41de-9893-a4399330264b)

or


![image](https://github.com/kirillzyusko/react-native-keyboard-controller/assets/22820318/c00f411e-d690-4f7a-bddf-a28c0a732381)

But when actual keyboard is tracked, then the frame of this keyboard has
non-zero height:


![image](https://github.com/kirillzyusko/react-native-keyboard-controller/assets/22820318/15c0ce28-f8c4-4c96-ad1f-35236a08e49e)

So to fix the problem with invalid keyboard view being found I decided
to modify a condition and add additional condition to check that
`frame.height != 0`.

Follow up for
#471
and
#338 (comment)

## 馃摙 Changelog

<!-- High level overview of important changes -->
<!-- For example: fixed status bar manipulation; added new types
declarations; -->
<!-- If your changes don't affect one of platform/language below - then
remove this platform/language -->

### iOS

- ignore keyboard view if its `height == 0`;

## 馃 How Has This Been Tested?

Tested on CI (e2e tests).

## 馃摑 Checklist

- [x] CI successfully passed
- [x] I added new mocks and corresponding unit-tests if library API was
changed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
馃悰 bug Something isn't working 馃崕 iOS iOS specific
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant