dominicstop / react-native-ios-context-menu

A react-native component to use context menu's (UIMenu) on iOS 13/14+
MIT License
572 stars 29 forks source link

The auxiliary element does not animate away when dismissing the context menu by pressing the preview element. #92

Open GaddiSunshine opened 9 months ago

GaddiSunshine commented 9 months ago

Pressing the preview element causes auxiliary element to not animate away. It just waits for the context menu to close and then snaps away

https://github.com/dominicstop/react-native-ios-context-menu/assets/55955275/b07f84a8-5ba0-4ce3-b74b-b8d0aeb41835

Expected behaviour: The auxiliary element would animate away like it does when pressing outside the preview element.

Actual behaviour: The auxiliary element does not animate away when dismissing the context menu by pressing the preview element.

Platform:

Versions:

"react-native": "0.72.6",
"expo": "49.0.18",
"react-native-ios-context-menu": "2.3.0",
"react-native-ios-utilities": "4.2.3",

Minimal reproducible example:

import React from 'react'
import { StyleSheet, View } from 'react-native'
import { ContextMenuView } from 'react-native-ios-context-menu'

const ContextMenuTest = () => (
  <View style={styles.root}>
    <ContextMenuView
      menuConfig={{
        menuTitle: '',
        menuItems: [
          {
            actionKey: 'cancel',
            actionTitle: 'Cancel',
          },
        ],
      }}
      renderAuxiliaryPreview={() => <View style={styles.auxiliaryElement} />}
    >
      <View style={styles.box} />
    </ContextMenuView>
  </View>
)

const styles = StyleSheet.create({
  root: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
  },
  box: {
    height: 50,
    width: 50,
    backgroundColor: 'blue',
  },
  auxiliaryElement: {
    backgroundColor: 'green',
    height: 50,
    width: 200,
  },
})

export default ContextMenuTest
ruairioliverwv commented 5 days ago

This patch fixed the issue for me, I apply it with patch-package. I have no need of the code in here but guessing it serves a purpose so I'm not creating a PR for it.

I just commented out all of the code that runs when the users presses on the preview. It still dismiss the preview and the animation works perfectly as if the user tapped the background.

Screenshot 2024-11-13 at 11 22 42

react-native-ios-context-menu+2.5.2.patch