dominicstop / react-native-ios-context-menu

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

Menu show/hide/cancel events are not fired for ContextMenuButton #98

Open finallyblueskies opened 6 months ago

finallyblueskies commented 6 months ago
<ContextMenuButton
  onMenuWillShow={() => {
    console.log("Show");
  }}
  onMenuWillHide={() => {
    console.log("Hide?");
  }}
  onMenuWillCancel={() => {
    console.log("Cancel");
  }}
  //...
>
  {/* ... */}
</ContextMenuButton>

I am finding that none of the events above (or any of the did/will show/hide/cancel events) are being fired as the menu is opened and closed.

This is my first time touching Swift code but I was able to discern that where the ContextMenuView UIContextMenuInteractionDelegate (RNIContextMenuView+UIContextMenuInteractionDelegate+.swift) functions were called when that menu opened/closed (and respective event callbacks were called) this does not happen for the ContextMenuButton equivalent (RNIContextMenuButton+UIContextMenuInteractionDelegate.swift). I was unable to make this work.

finallyblueskies commented 6 months ago

The React ContextMenuButton component seems to be completely detached from the underlying menu state, the class state menuVisible value for example never reflects the real state of the menu.