hackiftekhar / IQKeyboardManager

Codeless drop-in universal library allows to prevent issues of keyboard sliding up and cover UITextField/UITextView. Neither need to write any code nor any setup required and much more.
MIT License
16.35k stars 2.4k forks source link

Keyboard space is not removing insets from the ScrollView correctly #2042

Open douglasjunior opened 2 weeks ago

douglasjunior commented 2 weeks ago

Describe the bug

Hi @hackiftekhar, Douglas here again, the maintainer of React Native Keyboard Manager.

Recently I have updated the IQKeyboardManager from 6 to 7.0.2, and we can note several improvements and fixes in the library (including https://github.com/hackiftekhar/IQKeyboardManager/issues/1361 and https://github.com/hackiftekhar/IQKeyboardManager/issues/1422), thank you very much for that!

But also I found a new situation related to ScrollView in React Native, when using in a React Navigation screen.

To Reproduce

I dont know if you can run a React Native project, but to reproduce just run the Sample project branch 7-preview of the React Native Keyboard Manager.

  1. Clone the repo
  2. cd Sample
  3. ./install.sh
  4. And go!

Expected behavior

We expect that the extra bottom space to be removed when keyboard closes.

Screenshots

Version 7.0.2

keyboard manager

Version 6.5.16

keyboard manager version 6

Demo Project

https://github.com/douglasjunior/react-native-keyboard-manager/tree/master/Sample

Versions

Xcode: 15.2 Mac OS: 13.5.1 Simulator/Device: Simulator Simulator/Device Name: iPhone 15 Pro Max - iOS 17.2 Library Version: 7.0.2

Additional context

Looking to the log, seems that the insets are set wrong when the keyboard closes, I think that the bottom should be set to 0.0 instead of 420.0:

IQKeyboardManager| | old ContentInset: UIEdgeInsets(top: 0.0, left: 0.0, bottom: 376.0, right: 0.0) new ContentInset: UIEdgeInsets(top: 0.0, left: 0.0, bottom: 420.0, right: 0.0)

Debug log:

-[RTIInputSystemClient remoteTextInputSessionWithID:performInputOperation:]  perform input operation requires a valid sessionID
IQKeyboardManager|  >>>>> restorePosition() started >>>>>
IQKeyboardManager|  |   Restoring contentInset to: UIEdgeInsets(top: 0.0, left: 0.0, bottom: 0.0, right: 0.0)
IQKeyboardManager|  <<<<< restorePosition() ended: 0.002194624999901862 seconds <<<<<
-[RTIInputSystemClient remoteTextInputSessionWithID:performInputOperation:]  perform input operation requires a valid sessionID
IQKeyboardManager|  >>>>> addToolbarIfRequired() started >>>>>
IQKeyboardManager|  |   Found 20 responder sibling(s)
IQKeyboardManager|  <<<<< addToolbarIfRequired() ended: 0.01065550000021176 seconds <<<<<
IQKeyboardManager|  >>>>> adjustPosition() started >>>>>
IQKeyboardManager|  |   Need to move: -327.0, will be moving down
IQKeyboardManager|  |   Saving ScrollView New contentInset: UIEdgeInsets(top: 0.0, left: 0.0, bottom: 0.0, right: 0.0)
and contentOffset: (0.0, 0.0)
IQKeyboardManager|  |   old ContentInset: UIEdgeInsets(top: 0.0, left: 0.0, bottom: 0.0, right: 0.0) new ContentInset: UIEdgeInsets(top: 0.0, left: 0.0, bottom: 376.0, right: 0.0)
IQKeyboardManager|  <<<<< adjustPosition() ended: 0.0005828333341924008 seconds <<<<<
IQKeyboardManager|  >>>>> addToolbarIfRequired() started >>>>>
IQKeyboardManager|  |   Found 20 responder sibling(s)
IQKeyboardManager|  <<<<< addToolbarIfRequired() ended: 0.00037524999970628414 seconds <<<<<
IQKeyboardManager|  >>>>> adjustPosition() started >>>>>
IQKeyboardManager|  |   Need to move: -283.0, will be moving down
IQKeyboardManager|  |   old ContentInset: UIEdgeInsets(top: 0.0, left: 0.0, bottom: 376.0, right: 0.0) new ContentInset: UIEdgeInsets(top: 0.0, left: 0.0, bottom: 420.0, right: 0.0)
IQKeyboardManager|  <<<<< adjustPosition() ended: 0.0003427083320275415 seconds <<<<<

-[RTIInputSystemClient remoteTextInputSessionWithID:performInputOperation:]  perform input operation requires a valid sessionID
douglasjunior commented 2 weeks ago

Just to add more information about my debug, If I force the ignoreContentInsetAdjustment prop to true, then the ScrollView bottom space disappears after keyboard closes and the user scroll the screen.

image

keyboard manager 2