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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

keyboardWillShow not triggered in Android #3468

Closed
ortutay opened this issue Oct 16, 2015 · 45 comments
Closed

keyboardWillShow not triggered in Android #3468

ortutay opened this issue Oct 16, 2015 · 45 comments
Labels
Resolution: Locked This issue was locked by the bot.

Comments

@ortutay
Copy link

ortutay commented Oct 16, 2015

I am registering for keyboardWillShow like this:

this.addListenerOn(RCTDeviceEventEmitter, 'keyboardWillShow', this.updateKeyboardSpace);

This works fine in iOS, but in Android it does not trigger the event as expected. keyboardDidShow does work in Android.

@satya164
Copy link
Contributor

I can confirm this.

@hufeng
Copy link

hufeng commented Oct 19, 2015

Yes, we have the same problem.

@yychun1217
Copy link

so it is not supported in Android?

@ide
Copy link
Contributor

ide commented Nov 4, 2015

Keyboard events are unimplemented on Android.

@satya164
Copy link
Contributor

satya164 commented Nov 4, 2015

@yychun1217 KeyboardDidShow and KeyboardDidHide works on Android, so I guess whatever you wanted to do with will show events, you could do on did show instead.

@matth3wga0
Copy link

@satya164 Both KeyboardDidShow and keyboardWillShow events will not been triggered on Android, as I've set android:windowSoftInputMode to adjustResize.

componentDidMount() {
  DeviceEventEmitter.addListener('KeyboardDidShow', e => {
    // Nope
  });

  DeviceEventEmitter.addListener('keyboardWillShow', e => {
    // Nope
  });
}

@satya164
Copy link
Contributor

@matth3wga0 I'm using adjustResize and KeyboardDidShow and KeyboardDidHide work just fine. - https://github.com/scrollback/io.scrollback.neighborhoods/blob/master/app/views/keyboard-spacer.js

@matth3wga0
Copy link

@satya164 I'm using v0.14.2 and running on Android 5.1, what's yours?

@satya164
Copy link
Contributor

@matth3wga0 Was using 0.12 previously, now using 0.15-rc, on Android 5.1.

@matth3wga0
Copy link

@satya164 Thanks, I'll have a try with 0.15-rc.

@Sh3rawi
Copy link

Sh3rawi commented Jan 12, 2016

Im using RN 0.18-rc with a Moto X 5.1, keyboardDidHide and keyboardDidShow are both triggered on the showing of the keyboard (Actually, keyboardDidHide is triggered before DidShow!).
screen shot 2016-01-12 at 11 06 15 pm

Nothing is triggered on the hiding of the keyboard.

@kristjanmik
Copy link

keyboardWillShow and keyboardDidHide are not in RN 0.18-rc

@jblack10101
Copy link

+1 for interest

@motiazu
Copy link

motiazu commented Feb 15, 2016

+1
Iv'e been trying any way I could find, it looks like any method of knowing when the keyboard is up and it's height does not work anymore :(

Does anyone have a workaround for this?

@Iliyass
Copy link

Iliyass commented Feb 17, 2016

+1 RN: 18.1, Android: 5.0.2, Device: LG G2

@skv-headless
Copy link
Contributor

I use keyboardDidHide and keyboardDidHide here is source code

@zoharlevin
Copy link

+1 this still doesn't work in android

@zoharlevin
Copy link

ok, i somehow missed this, so...
for anybody who was confused (like me :)) i can confirm that keyboardWillShow + keyboardWillHide don't work on android but keyboardDidShow and keyboardDidHide do work on android.

thanks @skv-headless

@motiazu
Copy link

motiazu commented Feb 24, 2016

@zoharlevin Holy crap it works! Thanks!

@Iliyass
Copy link

Iliyass commented Feb 24, 2016

it works, thanks man

On Wed, Feb 24, 2016 at 9:03 AM, motiazu notifications@github.com wrote:

@zoharlevin https://github.com/zoharlevin Holy crap it works! Thanks!


Reply to this email directly or view it on GitHub
#3468 (comment)
.

@GantMan
Copy link
Contributor

GantMan commented Mar 14, 2016

@christopherdro
I see this was closed, but I don't see why. Is there a PR that fixes this? I'd like to follow whatever version it will be released with, if so.

NOTE I don't think keyboardDidShow is a sufficient replacement for keyboardWillShow

@christopherdro
Copy link
Contributor

@GantMan
This was closed because this is more of a missing feature than an actual bug.
Lately we've been trying to reduce the amount of issues down to actual bugs with the core project.

Feel free to submit a PR adding this functionality and link it back to this thread.

GlebkaF added a commit to GlebkaF/react-native that referenced this issue Mar 27, 2017
According to this issue: facebook#3468 , only `keyboardDidShow`and `keyboardDidHide` events are available on android. 

I think this information should be displayed in the documentation since default `android:windowSoftInputMode` is `adjustResize`.
GlebkaF added a commit to GlebkaF/react-native that referenced this issue Mar 27, 2017
According to this issue: facebook#3468 , only `keyboardDidShow`and `keyboardDidHide` events are available on android. 

I think this information should be displayed in the documentation since default `android:windowSoftInputMode` is `adjustResize`.
facebook-github-bot pushed a commit that referenced this issue Apr 5, 2017
Summary:
What existing problem does the pull request solve?

According to this issue: #3468 , only `keyboardDidShow`and `keyboardDidHide` events are available on android at this moment.

I think this information should be displayed in the documentation since default `android:windowSoftInputMode` is `adjustResize`.
Closes #13155

Differential Revision: D4795828

Pulled By: hramos

fbshipit-source-id: 2c114f3040808a5cc3cdeb29b2067877df353620
@superandrew213
Copy link

@christopherdro why was this closed? In the docs it says that all event should fire for both iOS and Android: https://facebook.github.io/react-native/docs/keyboard.html

If some events have not been implemented yet, then the docs should be updated to reflect that some events are iOS only.

@superandrew213
Copy link

@otoinsa you can try using react-native-android-keyboard-adjust if it helps. It allows you to dynamically change the windowSoftInputMode

thotegowda pushed a commit to thotegowda/react-native that referenced this issue May 7, 2017
Summary:
What existing problem does the pull request solve?

According to this issue: facebook#3468 , only `keyboardDidShow`and `keyboardDidHide` events are available on android at this moment.

I think this information should be displayed in the documentation since default `android:windowSoftInputMode` is `adjustResize`.
Closes facebook#13155

Differential Revision: D4795828

Pulled By: hramos

fbshipit-source-id: 2c114f3040808a5cc3cdeb29b2067877df353620
@rendomnet
Copy link

keyboardWillShow/keyboardWillHide still not working on Android?
I have no "android:windowSoftInputMode : adjustResize or adjustNothing" and still cant get keyboardWillShow/keyboardWillHide to work.

@m860
Copy link

m860 commented Jul 10, 2017

same issue , react native version is 0.44.0

@carlosconnected
Copy link

This is working on 0.46

@MyTotoro
Copy link

MyTotoro commented Aug 1, 2017

@carlos-peru where is this documented? thanks

@Ashoat
Copy link
Contributor

Ashoat commented Aug 2, 2017

keyboardWillShow/keyboardWillHide still not working for me on Android and RN 0.47.0

@danReynolds
Copy link
Contributor

The documentation says:

Note that if you set android:windowSoftInputMode to adjustResize or adjustNothing, only keyboardDidShow and keyboardDidHide events will be available on Android. keyboardWillShow as well as keyboardWillHide are generally not available on Android since there is no native corresponding event.

Does that mean adjustPan works for example? That first sentence seems to imply keyboardWillShow and keyboardWillHide is available on other input modes.

@NikolaRavic
Copy link

Note that if you set android:windowSoftInputMode to adjustResize or adjustNothing, only keyboardDidShow and keyboardDidHide events will be available on Android. keyboardWillShow as well as keyboardWillHide are generally not available on Android since there is no native corresponding event.

I can confirm that if you set android:windowSoftInputMode to adjustNothing none of events are available for Android.

@Titozzz
Copy link
Collaborator

Titozzz commented Oct 9, 2017

I also need the event when android:windowSoftInputMode is adjustNothing 😢

@johngoren
Copy link

I can't get windowSoftInput mode to work reliably, and KeyboardAvoidingView is hard to debug so I was hoping to get at this feature more directly in Android. But it's not working. RN 49.

jainkuniya added a commit to jainkuniya/zulip-mobile that referenced this issue Nov 19, 2017
borisyankov pushed a commit to zulip/zulip-mobile that referenced this issue Nov 19, 2017
* [iOS] Move message content up when keyboard pops up.

* [Android] Update offset onLayout.

Manually determine new offset at the time of keyboard dismiss.

* Removed log statements.

* Removed unused variables.

* Fix: flow errors.

* Fix: listComponent and _scrollOffset undefined error.

* Adjust scroll position just before keyboard toggle.

Listen to keyboardWillShow & keyboardWillHide instead of keyboardDidShow && keyboardDidHide.

* Fix: sometimes list is scrolled randomly when keyboard toggles.

* Scroll to end when ~50% to ~99% screen is occupied.

* Fix: list is scrolled to end when list is at top and keyboard pops.

* Listen to KeyboardDidShow and KeyboardDidHide for Android.

As keyboardWillShow and KeyboardWillHide are not fired on Android.

facebook/react-native#3468

https://facebook.github.io/react-native/docs/keyboard.html
@sabbyt54
Copy link

+1 confirmed no event when android:windowSoftInputMode is adjustNothing

@northern
Copy link

I'm running into the same problem in that the keyboardDidShow and keyboardDidHide are only fired on Android when the android:windowSoftInputMode is set to adjustResize.

However, when the android:windowSoftInputMode is set to adjustResize then when you're using a TabNavigator from the React Navigation package, when the keyboard on Android shows, it pushes the tabbar (if it's aligned at the bottom) up with the keyboard. To work around this pushing up you can set android:windowSoftInputMode is set to adjustNothing but doing this means that your content (text fields etc.) are behind your keyboard.

On iOS I've been working around this problem by adding a spacer View with a height of the keyboard at the end of my view when the keyboard opens, but since the event doesn't fire, this work around doesn't work for Android.

So, at the moment, on Android you can either have keyboard events (with adjustResize) but you will have a pushed up TabNavigator or you can have a hidden TabNavigator and no keyboard events.

It's a bit of a pickle...

@kkotkkio
Copy link

It's works both iOS and Android.

state = {
 btnLocation: 0
}
  componentWillMount() {
    this.keyboardDidShowListener = Keyboard.addListener('keyboardDidShow', this._keyboardWillShow.bind(this));
    this.keyboardDidHideListener = Keyboard.addListener('keyboardDidHide', this._keyboardWillHide.bind(this));
  }
  componentWillUnmount () {
    this.keyboardDidShowListener.remove();
    this.keyboardDidHideListener.remove();
  }

  _keyboardWillShow(e) {
    this.setState({btnLocation: e.endCoordinates.height});
  }
  _keyboardWillHide(e) {
    this.setState({btnLocation: 0})
  }

@cathy810218
Copy link

cathy810218 commented Mar 30, 2018

@kkotkkio I don't think that works the way we want it to. You're still doing keyboardDidShow and keyboardDidHide, you are just calling the functions and name those functions WILL - keyboardWillShow and keyboardWillHide but it doesn't make sense. Those functions are fired AFTER keyboard is shown instead of BEFORE.

@cihadturhan
Copy link

I know I'm beating the dead horse here but the issue opened in Oct 2015 and it's still not working in 2018 at RN 55.4

@ngocnguyen09910060
Copy link

I'm facing same issue when android:windowSoftInputMode is adjustNothing.
Hi Mr @northern, have you resolved this issue ?

@ArturDrozdz
Copy link

Still the same on Android.

re-open mkayyy

@Billy-
Copy link

Billy- commented Jul 16, 2018

@christopherdro @shergin Can someone explain why this was closed please?

@facebook facebook locked as resolved and limited conversation to collaborators Jul 21, 2018
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Jul 21, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests