react-native-keyboard-aware-scroll-view icon indicating copy to clipboard operation
react-native-keyboard-aware-scroll-view copied to clipboard

extraScrollHeight cause bottom empty space

Open andrej-kuznetsov opened this issue 6 years ago • 20 comments

I have bottom empty space, it cause extraScrollHeight

"react-native-keyboard-aware-scroll-view": "^0.8.0",
"react-native": "0.55.4",

My code

<KeyboardAwareScrollView
    style={ { flex: 1 } }
    extraScrollHeight={ this.props.extraScrollHeight }
    keyboardShouldPersistTaps='handled'
    contentContainerStyle={ { width: responsiveWidth(100) } }
    enableOnAndroid
>
// CONTENT
</KeyboardAwareScrollView>

hello09

andrej-kuznetsov avatar Jan 26 '19 17:01 andrej-kuznetsov

In case double tap for hiding keyboard double

andrej-kuznetsov avatar Jan 26 '19 17:01 andrej-kuznetsov

For me, the quickest fix is to pass scrollEnabled={ false }.But it forbid user to scroll, it just suitable fix for my case, and it isn't properly way of fixing this bug.

andrej-kuznetsov avatar Jan 26 '19 22:01 andrej-kuznetsov

any update on this?

mdnahian avatar Feb 12 '19 03:02 mdnahian

I don't think it's related to extraScrollHeight I've got this problem without the extraScrollHeight property.

SaltySammy avatar Feb 23 '19 14:02 SaltySammy

same problem here

OsamaSaleem95 avatar Apr 16 '19 05:04 OsamaSaleem95

Any solution for this problem? Here, the same problem :(

ataschz avatar May 07 '19 22:05 ataschz

The library adds padding. I just edit that lines in render method(KeyboardAwareHOC.js), it solved my problem. But this is not the best way.

 if (Platform.OS === 'android' && enableOnAndroid) {
        newContentContainerStyle = [].concat(contentContainerStyle).concat({
          paddingBottom:
            ((contentContainerStyle || {}).paddingBottom || 0) +
            this.state.keyboardSpace
        })
      }

to

 if (Platform.OS === 'android' && enableOnAndroid) {
        newContentContainerStyle = [].concat(contentContainerStyle).concat({
          paddingBottom:
            ((contentContainerStyle || {}).paddingBottom || 0)
        })
      }

DIMASIK1502 avatar May 17 '19 12:05 DIMASIK1502

You don't need change in Lib, you can add this line to KeyboardAwareFlatList contentContainerStyle={Platform.OS == 'android' ? { paddingBottom: -this.state.keyboardHeight } : {}}

duyenhang avatar Jun 28 '19 07:06 duyenhang

Any solution found yet?

I've been experiencing this issue on android. Nothing to do with scrollHeight but it only happens when i add enableOnAndroid={true}

jsam6 avatar Oct 03 '19 08:10 jsam6

I've found the solution for this problem (at least for my case).

I added style = {{ flex: 1, minHeight: Dimensions.get('window').height }} to KeyboardAwareScrollView.

jsam6 avatar Oct 03 '19 09:10 jsam6

I've the same issue. Both iOS & Android are affected.

dkoprowski avatar Oct 31 '19 12:10 dkoprowski

@dkoprowski try using native-base instead

import { Content } from 'native-base';

<Content extraScrollHeight={heightofkeyboard}  enableOnAndroid>
// children
</Content>

jsam6 avatar Nov 01 '19 03:11 jsam6

In ScrollView, flex properties will be applied by contentContainerStyle.

<KeyboardAwareScrollView
        contentContainerStyle={{flex: 1}}
>

It will help you.

darkhorse-coder avatar Jan 15 '21 15:01 darkhorse-coder

Maybe this will help: https://github.com/APSL/react-native-keyboard-aware-scroll-view/issues/289#issuecomment-777094398

devinjameson avatar Feb 10 '21 23:02 devinjameson

In ScrollView, flex properties will be applied by contentContainerStyle.

<KeyboardAwareScrollView
        contentContainerStyle={{flex: 1}}
>

It will help you.

Worked perfectly for me. Not sure why it got two thumbs down...

raffibag avatar Apr 29 '21 03:04 raffibag

Found a fix, use:

<KeyboardAwareScrollView
    contentInset={{ top: 0, bottom: 0 }}
>

alecdewitz avatar Dec 12 '21 07:12 alecdewitz

  const [contentBottom, setContentBottom] = useState(0);

      <KeyboardAwareScrollView
          style={{
            flex: 1,
            backgroundColor: Color.white,
          }}
          keyboardOpeningTime={0}
          extraScrollHeight={150}
          enableResetScrollToCoords
          onKeyboardWillHide={() => setContentBottom(0)}
          onKeyboardWillShow={() => setContentBottom(200)}
          contentInset={{ bottom: contentBottom }}
        >

This solution might help. Add the values that are suitable for bottom

SrikanthNandanaboina avatar Dec 25 '21 14:12 SrikanthNandanaboina

  const [contentBottom, setContentBottom] = useState(0);

      <KeyboardAwareScrollView
          style={{
            flex: 1,
            backgroundColor: Color.white,
          }}
          keyboardOpeningTime={0}
          extraScrollHeight={150}
          enableResetScrollToCoords
          onKeyboardWillHide={() => setContentBottom(0)}
          onKeyboardWillShow={() => setContentBottom(200)}
          contentInset={{ bottom: contentBottom }}
        >

This solution might help. Add the values that are suitable for bottom

This works tested on iPhone 13 and iPhone 13 Pro Max but not on iPhone SE (3rd generation)

kitkatMielPineda avatar Sep 08 '22 10:09 kitkatMielPineda

I got a solution on this.. Tested on iPhone 13, iPhone 13 Pro Max, iPhone 6s, iPhone SE (3rd generation) and android.

try:

import React, {useEffect, useState} from 'react';
import { useWindowDimensions} from 'react-native';
import useKeyboardHeight from 'react-native-use-keyboard-height'


  const [contentBottom, setContentBottom] = useState(0);
  const [keyboardActive, setKeyboardActive] = useState(false)

  const {height} = useWindowDimensions()
  const keyHeight = useKeyboardHeight()

  useEffect(()=>{  
    if (keyboardActive){
      const diff = (parseFloat((height - keyHeight)/2))
      setContentBottom(diff)
    } else{
      setContentBottom(0)
    }
  },[keyHeight, keyboardActive]
  
<KeyboardAwareScrollView
            keyboardOpeningTime={0}
            enableResetScrollToCoords
            onKeyboardWillHide={() => setKeyboardActive(false)}
            onKeyboardWillShow={()=>setKeyboardActive(true)}
            contentInset={{ bottom: contentBottom }}
            automaticallyAdjustKeyboardInsets={true}
            automaticallyAdjustContentInsets={false}
          >

Previous

with extra white space at the bottom of the background image and before the keyboard for iPhone 13 Screen Shot 2022-09-08 at 12 04 24 PM

Changes

no extra white space anymore Screen Shot 2022-09-08 at 10 32 29 PM Screen Shot 2022-09-08 at 10 18 06 PM

goodnight everyone!

kitkatMielPineda avatar Sep 08 '22 14:09 kitkatMielPineda