React-native-screens: NativeScreenContainer seems blocking android context menu to show up

Created on 28 Oct 2019  Â·  11Comments  Â·  Source: software-mansion/react-native-screens

"react-navigation": "^3.9.1",
"react-native": "^0.61.2",

I am using react navigation stack which uses this library. I was not able to bring android context menu without a force refresh.

This is the issue https://github.com/react-navigation/react-navigation/issues/5476

I am able to get the context menu if I remove NativeScreenContainer from react native stack/StackViewLayout

      <PanGestureHandler
        {...this._gestureActivationCriteria()}
        ref={this.panGestureRef}
        onGestureEvent={this.gestureEvent}
        onHandlerStateChange={this._handlePanGestureStateChange}
        enabled={index > 0 && this._isGestureEnabled()}
      >
        <Animated.View
          style={[styles.container, this._transitionConfig.containerStyle]}
        >
          <StackGestureContext.Provider value={this.panGestureRef}>
            {/* <ScreenContainer style={styles.scenes}> */}
              {scenes.map(this._renderCard)}
            {/* </ScreenContainer> */}
            {floatingHeader}
          </StackGestureContext.Provider>
        </Animated.View>
      </PanGestureHandler>

Most helpful comment

Many thanks to @compojoom for investigatint this issue – your tips saved me a lot of time and managed to come up with a fix. Also wanted to thank @tombarton for providing me with the repro case. I'll merge the fix in the next couple of days and publish a new release.

All 11 comments

Yes. This is causing several other issues on Android. The Autofill is not able to show suggestions as well due to this. Would really like pointers on what can cause this...

I can confirm that this happens with the latest alpha32. One has to resort to stupid tricks such as:

const [width, setWidth] = useState("99.9%")

  useEffect(() => {
    setTimeout(()=> {
      setWidth("100%")
    }, 0)
  })

and then applying the with as style on the TextInput. Doing this shows the context menu, but it's just a hack.

When not using the setWidth hack in logcat I'm noticing this:

W/TextView: TextView does not support text selection. Selection cancelled.

A google search brings us here: https://stackoverflow.com/questions/15857755/android-textview-does-not-support-text-selection-action-mode-cancelled and one of the comments suggests to setWidth on the textview. So maybe we are running in some kind of a bug with android.
https://issuetracker.google.com/issues/36984016

@kmagiera @satya164 @osdnk suggestions?

Just wanted to paste here the report from @tombarton from #210 as he'd provided a reproducible example:

Copy/paste appears to be breaking in Android when react-native-screens is used with react-navigation 4.0.10. I've replicated the issue using React Navigation's "Get Started" example in both Expo snack and a standalone repo.

Versions:

"react": "16.8.3",
"react-native": "0.60.5",
"react-native-gesture-handler": "1.3.0",
"react-native-screens": "^2.0.0-alpha.7",
"react-navigation": "4.0.10",
"react-navigation-stack": "1.9.3"

Replicable repo:

Expo Snack: snack.expo.io/@tombarton/react-native-screens-copy-paste-android
GitHub Repo: tombarton/react-native-screens-copy-paste

As a hacky workaround, toggling the editable property after it's initial render also seems to also fix it

https://snack.expo.io/HJDO_9dzI

Many thanks to @compojoom for investigatint this issue – your tips saved me a lot of time and managed to come up with a fix. Also wanted to thank @tombarton for providing me with the repro case. I'll merge the fix in the next couple of days and publish a new release.

Any luck on the merge of this one @kmagiera ? I see you doing great pumping out new betas, but as far as I can tell, this one is still an issue on the latest. Thanks!

Edit: actually, it seems to be working now after force restarting the app

Great, closing this as the fix has been out for a few releases already.

not working for me, any suggest?

"react": "16.9.0",
"react-native": "0.61.5",
"react-native-screens": "^2.3.0",
"react-navigation": "^4.1.0"

just updated from "react-native-screens": "^2.0.0-alpha.32" to "react-native-screens": "^2.3.0" but the issue is still there

I dont want to use the setTimeout() workaround, thanks for your time

yes, it seems issues still exist. I uploaded a repo here : https://github.com/ovy9086/rn-autofill-bug
seems like it's related/duplicate of https://github.com/software-mansion/react-native-screens/issues/349 ?

I faced this issue too. Enabling screens with the latest react-native-screens and react-navigation helped:

import { enableScreens } from 'react-native-screens';

enableScreens();

Packages:

"react": "^16.14.0",
"react-native": "0.63.4",
"@react-navigation/bottom-tabs": "^5.11.8",
"@react-navigation/native": "^5.9.3",
"@react-navigation/stack": "^5.14.3",
"react-native-screens": "^2.18.0"
Was this page helpful?
0 / 5 - 0 ratings