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

How to set menu position always bottom? #102

Open
crusherblack opened this issue May 5, 2024 · 7 comments
Open

How to set menu position always bottom? #102

crusherblack opened this issue May 5, 2024 · 7 comments

Comments

@crusherblack
Copy link

crusherblack commented May 5, 2024

Hi i want to set the menu position to bottom only so the aux preview not overlapping each others

image

I want it to be like this everytime hold the item

image

Can you help me?
Thank you

@alexrisch
Copy link

@crusherblack did you find a way to do this?

@acdifran
Copy link

acdifran commented Oct 29, 2024

I am running into the same issue using zeego which uses this library for ios. I found that rendering a separate preview of the same content will keep the menu on the bottom, but introduces a small flicker: nandorojo/zeego#107. I've been poking around the source code to see if I can find a way to keep the menu on the bottom without the flicker, but no luck so far.

@acdifran
Copy link

acdifran commented Nov 5, 2024

After digging around a bit more I found that commenting out the highlightPreview and dismissalPreview interactions in RNIContextMenuView+UIContextMenuInteractionDelegate.swift solves the flicker. I think it's related to this currently always being set to self.menuTargetedPreview which is either an actual targeted preview that you specify or the current view (self) if there's no targeted preview. This might be causing the flicker when you use a custom preview since the view used for the preview interactions is then different from the preview itself. Obviously just commenting out this code is not a great solution since I imagine it would break the use of an actual targeted preview. @dominicstop any thoughts on this? I tried creating a targetedPreview with the view created by the previewProvider, but that didn't seem to work. I'm not well versed in swift or UIKit, so not sure what a good solution here would be.

before after
ScreenRecording_11-05-2024.09-27-16_1.MP4
ScreenRecording_11-05-2024.09-24-38_1.MP4

@dominicstop
Copy link
Owner

dominicstop commented Nov 5, 2024

@acdifran hello, thank you for the detailed response and for bumping this issue

i apologize for responding so late, this issue kind of got buried in my emails (so this is the first time i am seeing this)

to start things of, i need to make a test to repro this; can i ask what version of the library you are using?

unfortunately, i can only work on a fix for this in the latest pre-release major version

i might be able to backport it though if it's relatively simple

@acdifran
Copy link

acdifran commented Nov 5, 2024

hey @dominicstop thanks for looking into this! I am on 2.5.1. I tried upgrading to v3, but seems it is not set up to work with expo, is that right?

@dominicstop
Copy link
Owner

dominicstop commented Nov 5, 2024

@acdifran hello, yes unfortunately i haven't tested it with expo yet; i just haven't had the time to do it since i'm no longer doing OSS for the time being.

the scaffolding + example app for v3 of this library was generated by react-native-builder-bob. I've been meaning to create another example directory/app using expo, but i don't really know how to set that up, unfortunately.

if you happen to know how, i would be grateful if you could help me set that up, so i can continue testing; here's a testfllight version of the example app just in case you need it (i think it might have gotten fix during the rewrite): https://testflight.apple.com/join/VsNeSTPq

i think it should still work with zeego, since i haven't really changed much of the API (though i did remove some of the internal cleanup stuff).

if you have time, can you please try installing: [email protected] + [email protected] and see if there are any problems? i'll release patches to fix the errors you encounter.

Edit: Hello, i added an example for expo, and it seems to work just fine.

Screenshot 2024-11-07 at 1 44 32 AM



please reply w/ min. example code to reproduce this bug so i can investigate; thank you

@acdifran
Copy link

acdifran commented Nov 8, 2024

hey @dominicstop just seeing your latest message above, thanks for putting up an expo example. I added a second example where the preview is the same as the main content where you can see the flicker.

ScreenRecording_11-08-2024.09-09-35_1.MP4

here's the code for the new example:

export function FlickerExample({ children }: { children: React.ReactElement }) {
  return (
    <ContextMenuView
      style={styles.menuContainer}
      previewConfig={{ previewType: "CUSTOM" }}
      renderPreview={() => children}
      menuConfig={{
        menuTitle: "BasicUsageExample01",
        menuItems: [
          {
            actionKey: "key-01",
            actionTitle: "Action #1",
          },
          {
            actionKey: "key-02",
            actionTitle: "Action #2",
          },
          {
            actionKey: "key-03",
            actionTitle: "Action #3",
          },
        ],
      }}
    >
      {children}
    </ContextMenuView>
  );
}

export default function App() {
  return (
    <View style={styles.container}>
      <StatusBar style="auto" />
      <BasicUsageExample01 />
      <FlickerExample>
        <Text style={styles.text}>Press And Hold To Show Context Menu</Text>
      </FlickerExample>
    </View>
  );
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants