Coder Social home page Coder Social logo

zeego's Introduction

Frame 32

Beautiful, native menus for React Native + Web, inspired by Radix UI.

  • 🕺 Radix UI on Web
  • 🛫 Native elements on iOS/Android (where possible)
  • 🌲 Same API cross-platform
  • 🌊 Works with Solito and Next.js
  • 🤖 Supports Expo (with custom dev clients)
  • 🍦 Vanilla React Native too
  • 🎨 100% unstyled components

Documentation

zeego's People

Contributors

nandorojo avatar fobos531 avatar michaelkremenetsky avatar intergalacticspacehighway avatar arvidnilber avatar alantoa avatar just-moh-it avatar biw avatar sn0wye avatar ouwargui avatar kacperkapusciak avatar than-de avatar marceloprado avatar randall71 avatar nderscore avatar sidorchukandrew avatar

Stargazers

Connor Howell avatar Santiago Galán avatar Mitchell Seaton avatar  avatar  avatar Emerson Vieira avatar Hassan Shah avatar ELABBASSI Hicham avatar Abhisek Kumar Anand avatar Abdulsamad Suleiman avatar John avatar  avatar Yu Zheng avatar William avatar youssef oussama avatar Mohammed Benkhattab avatar Thanh Binh Nguyen avatar Tewodros Birhanu avatar Hyeonwoo KOO avatar Vũ Tiến Phát avatar Aadi avatar Brad Pillow avatar  avatar Dohan avatar Florian Knop avatar Alberto Gallego avatar David Bašelj avatar  avatar Anton avatar Rakesh Merugu avatar Ji Yong, Kim avatar Ragil Burhanudin Pamungkas avatar Guillaume Chx avatar Jan Kott avatar  avatar Mike Chong avatar Alex Ishutin avatar Muammer Topçu avatar Bishwajeet Parhi avatar Prince Ofori avatar Lukas Schulte Pelkum avatar Aloy Sathekge avatar Konstantin W. avatar Yağız Ceritoğlu avatar  avatar Wan-Huang Yang avatar Birol AYDIN avatar Brayan Yévenes  avatar Zeema avatar Fellipe Utaka avatar Harry avatar Mauricio Alexandre avatar DongWook Kim avatar ogulcan eristi avatar Dmitry avatar enfpdev avatar Vladyslav avatar Onur avatar Sébastien Raynaud avatar Daniel avatar ppichier avatar  avatar Mia Loha.dev avatar Eduard Farkaš avatar Thien Nguyen avatar ILIYA avatar Tomoki Kamo avatar Dmytro Trubin avatar Çağatay avatar Fiifi Foh Arkhurst Jr. avatar Luís Gustavo avatar MyCloudVIP® Corporation avatar Karan Tondare avatar  avatar Alfred Nwanokwai avatar Daniel Boros avatar Minhaz Mohammad avatar  avatar Ethan Lin avatar Gustavo Bonfim avatar Brian Jorda avatar Pablo Fernandez avatar Gustav Bang avatar TimoDevs avatar Ryan Hearne avatar Alaister Young avatar  avatar Abbas Kareem avatar Leonardo Cavalcante avatar Adam Horodyski avatar Deniz Utku Beydogan avatar Foaad avatar Timothy avatar Kosick avatar Damien Parbhakar avatar Bartlomiej Sworzen avatar Karl Lopez avatar Victor Chagas Seibert avatar Guillaume Dumoulin avatar Gibran Dimasagung avatar

Watchers

Kwamena Appiah-Kubi avatar James Cloos avatar Michael Demarais avatar Axel Delafosse avatar  avatar  avatar  avatar  avatar

zeego's Issues

Catch upstream crash

This is great library taking care of both iOS and Android! After switching to this library, I start to notice a new app crash caused by the upstream react-native-ios-context-menu. I still yet to find out under what circumstances such crash would happen, but this is the line where things go wrong https://github.com/dominicstop/react-native-ios-context-menu/blob/master/src/functions/Helpers.ts#L80. I guess we can catch the error softly to prevent hard crash in this library? Thanks!

Context and Dropdown menus are not working in sheets

Hey @nandorojo! I recently noticed an issue when both context and dropdown menus stopped working in sheet screens. They are implemented with stack navigator and @gorhom bottom sheet modal which uses portal under the hood (I thought this can be an issue, but was not before). Both of the menus are working on initial stack screen.

I'll append the video demo to highlight the issue. In the demo the component that you can see initially uses exactly the same component that "more actions" button uses in the sheet screen. Also, the "Create transaction" button uses the dropdown menu as you can see by the zoom effect, but it just doesn't open

Any help would be appreciated. Thanks in advance!

Media

Simulator.Screen.Recording.-.iPhone.14.Pro.-.2023-05-12.at.15.33.14.mp4

using a very tall view as preview causes preview to get cropped

amazing work on zeego. I was able to drop this into my app pretty effortlessly. So cool and thanks for building it!

One issue I am running into: if I use a very tall view as my preview component, it appears to get "cut off" on the sides.

My usecase: I am building an app where users can write posts. If you long-press a post, you get a context menu. This works well for short posts, but for long posts, they get cut off. See attached video.

Simulator.Screen.Recording.-.iPhone.14.Pro.-.2023-07-17.at.17.30.32.mp4

Any idea how I can fix this? I would expect the entire view to be scaled appropriately to fit into the viewport.

[Enhancement] Support Expo Go

Thank you for this awesome lib 👍

Is it planned to support Expo Go without a custom development client on iOS?
I know this is related to the usage of react-native-ios-context-menu, but is there a solution planned to make it compatible with Expo Go?

Build error on Android for `react-native-ios-context-menu`

Hey @nandorojo! First of all, thank you for one more amazing library.
I understand that it's more like a wrapper around react-native-ios-context-menu, but while using zeego with expo and EAS, I'm facing issue while building any releases (both development and production). I created an issue (link) on the original library repo, but no answer was received. Maybe you faced an issue during development?

Stack trace

[stderr] e: Incompatible classes were found in dependencies. Remove them from the classpath or use '-Xskip-metadata-version-check' to suppress errors
[stderr] e: /home/expo/.gradle/caches/transforms-3/2cfe106a332c6a6f2245988cf5920bcb/transformed/jetified-kotlin-stdlib-common-1.6.10.jar!/META-INF/kotlin-stdlib-common.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.6.0, expected version is 1.1.15.
[stderr] e: /home/expo/.gradle/caches/transforms-3/8fa201288e2c6500b9e1af2f8ed9c77c/transformed/jetified-kotlin-stdlib-jdk7-1.6.10.jar!/META-INF/kotlin-stdlib-jdk7.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.6.0, expected version is 1.1.15.
[stderr] e: /home/expo/.gradle/caches/transforms-3/b6d16718b0badf943a01bd505b26edc1/transformed/jetified-kotlin-stdlib-jdk8-1.6.10.jar!/META-INF/kotlin-stdlib-jdk8.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.6.0, expected version is 1.1.15.
[stderr] e: /home/expo/.gradle/caches/transforms-3/d3fc290c9b603f2d0c573f31aa64957d/transformed/jetified-kotlin-stdlib-1.6.10.jar!/META-INF/kotlin-stdlib.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.6.0, expected version is 1.1.15.
[stderr] e: /home/expo/.gradle/caches/transforms-3/ef154a7ff5c9e83f423d62f01250b0da/transformed/jetified-react-native-0.70.5-debug-api.jar!/META-INF/ReactAndroid_debug.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.6.0, expected version is 1.1.15.
[stderr] e: /home/expo/workingdir/build/node_modules/react-native-ios-context-menu/android/src/main/java/com/reactnativeioscontextmenu/IosContextMenuPackage.kt: (11, 16): Unresolved reference: emptyList
[stderr] e: /home/expo/workingdir/build/node_modules/react-native-ios-context-menu/android/src/main/java/com/reactnativeioscontextmenu/IosContextMenuPackage.kt: (15, 16): Unresolved reference: listOf
[stderr] e: /home/expo/workingdir/build/node_modules/react-native-ios-context-menu/android/src/main/java/com/reactnativeioscontextmenu/IosContextMenuViewManager.kt: (18, 10): Class 'kotlin.Unit' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.6.0, expected version is 1.1.15.
[stderr] The class is loaded from /home/expo/.gradle/caches/transforms-3/d3fc290c9b603f2d0c573f31aa64957d/transformed/jetified-kotlin-stdlib-1.6.10.jar!/kotlin/Unit.class

And the following trace in summary

[stderr] FAILURE: Build completed with 2 failures.
[stderr] 1: Task failed with an exception.
[stderr] -----------
[stderr] * What went wrong:
[stderr] Execution failed for task ':react-native-ios-context-menu:compileDebugKotlin'.
[stderr] > Compilation error. See log for more details
[stderr] * Try:
[stderr] > Run with --stacktrace option to get the stack trace.
[stderr] > Run with --info or --debug option to get more log output.
[stderr] > Run with --scan to get full insights.

Updating project's kotlin version to 1.6.0 gave no result

[SOLVED] Context menu crashes app when wrapping a navigation trigger

Hey first off thanks for the library!

On "zeego": "^1.7.0" I have noticed an issue where if you try to cancel opening the context menu just before it should open then you get the navigation & the menu opens then app crashes.

I pulled the code from the example and wrapped my ConversationPreview component with no changes. The component is pretty simple, just a Pressable with an expo-router router.push.

This is using "expo": "^49.0.9" in a dev client & "expo-router": "2.0.4".

If you can't replicate let me know and I can try create a repo.

Not a big enough issue to commit time to rn but thought I would let you know

Untitled.mov

Error "React is not defined" in monorepo

I have a bare react native app. React Native v0.70.4.
I installed both react-native-ios-context-menu and @react-native-menu/menu.
When I launch the project I get the following error "can't find variable: React in display-names.js" (cf attached image).
I am able to patch this by adding import React from 'react'; at the top of the display-names.js file.
Is there something I am doing wrong?

Simulator Screen Shot - iPhone 14 - 2022-12-21 at 16 16 45

Function execution delay in menu items

Hey! First of all thank you for amazing lib! While using it I noticed a delay between item press and function execution both in ContextMenu and DropdownMenu Item component's onSelect prop, this delay is absent with onPress prop for ContextMenu's Preview component for the same function though

Can not be installed on expo development client

I Am getting the following when i try to install this library in expo development client
npx expo install expo-build-properites
› Installing 1 other package using npm

npm install --save expo-build-properites
npm ERR! code E404
npm ERR! 404 Not Found - GET https://registry.npmjs.org/expo-build-properites - Not found
npm ERR! 404
npm ERR! 404 'expo-build-properites@*' is not in this registry.
npm ERR! 404
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.

npm ERR! A complete log of this run can be found in: /Users/mo3/.npm/_logs/2023-10-16T06_47_10_194Z-debug-0.log
Error: npm exited with non-zero code: 1
Error: npm exited with non-zero code: 1
at ChildProcess.completionListener (/Users/mo3/Desktop/Almanbar-cli/node_modules/@expo/spawn-async/build/spawnAsync.js:52:23)
at Object.onceWrapper (node:events:632:26)
at ChildProcess.emit (node:events:517:28)
at maybeClose (node:internal/child_process:1098:16)
at ChildProcess._handle.onexit (node:internal/child_process:303:5)
...
at spawnAsync (/Users/mo3/Desktop/Almanbar-cli/node_modules/@expo/spawn-async/build/spawnAsync.js:17:21)
at NpmPackageManager.runAsync (/Users/mo3/Desktop/Almanbar-cli/node_modules/@expo/package-manager/build/node/BasePackageManager.js:38:42)
at /Users/mo3/Desktop/Almanbar-cli/node_modules/@expo/package-manager/build/node/NpmPackageManager.js:39:20
at /Users/mo3/Desktop/Almanbar-cli/node_modules/@expo/package-manager/build/utils/spawn.js:19:34
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

I Am using expo SDK 49
latest react native, the way i install it is npx expo install expo-build-properites

Expose onOpenChange

I guess this might be hard to support cross-platform, but it would be great if it's possible. Radix has a onOpenChange callback that makes it possible to know whether a DropdownMenu is open or not. I'm thinking it might be worth to add it even if it's not possible cross-platform (should of course be made clear through JSDoc etc in that case)?

My specific use-case:
I needed this to be able to disable key listeners on web, so escape can work as expected

diff --git a/node_modules/zeego/lib/module/dropdown-menu/dropdown-menu.web.js b/node_modules/zeego/lib/module/dropdown-menu/dropdown-menu.web.js
index 9745390..b0a57e7 100644
--- a/node_modules/zeego/lib/module/dropdown-menu/dropdown-menu.web.js
+++ b/node_modules/zeego/lib/module/dropdown-menu/dropdown-menu.web.js
@@ -7,9 +7,12 @@ import * as DropdownMenu from '@radix-ui/react-dropdown-menu';
 
 const Root = _ref => {
   let {
-    children
+    children,
+    onOpenChange
   } = _ref;
-  return /*#__PURE__*/React.createElement(DropdownMenu.Root, null, children);
+  return /*#__PURE__*/React.createElement(DropdownMenu.Root, {
+    onOpenChange: (isOpen) => { onOpenChange && onOpenChange(isOpen) },
+  }, children);
 };
 
 Root.displayName = MenuDisplayName.Root;
diff --git a/node_modules/zeego/lib/typescript/menu/types.d.ts b/node_modules/zeego/lib/typescript/menu/types.d.ts
index 55b973b..c7f60d7 100644
--- a/node_modules/zeego/lib/typescript/menu/types.d.ts
+++ b/node_modules/zeego/lib/typescript/menu/types.d.ts
@@ -6,6 +6,7 @@ declare type TextStyle = React.ComponentProps<typeof Text>['style'];
 export declare type MenuRootProps = {
     children: React.ReactNode;
     style?: ViewStyle;
+    onOpenChange?: (open: boolean) => void;
 };
 export declare type MenuTriggerProps = {
     children: React.ReactElement;

This issue body was partially generated by patch-package.

[iOS] Trigger children component disappears when navigating back on react-navigation stack

On iOS, when navigating from a screen that uses DropdownMenu to a new screen, and then going back to the previous screens, the components inside DropdownMenu.Trigger disappears forever. See below for example and repro:

Demo

Screen.Recording.2022-07-22.at.9.53.44.PM.mov

Workaround

Set detachPreviousScreen: false on the next screen options which prevents the DropdownMenu from detaching in the first place, but may cause performance problems.

Repro

<DropdownMenu.Root>
  <DropdownMenu.Trigger>
    <ThemedChip
      key={availableOptions[0]}
      isSelected={!isDefault}
      label={capitalize(getChipLabel(chosenOption, type))}
      rightComponent={
        <ThemedIcon
          name="chevron-down"
          color={isDefault ? lightColors.primary : 'white'}
          size={16}
          style={tw('ml-1')}
        />
      }
    />
  </DropdownMenu.Trigger>
  <DropdownMenu.Content>
    {availableOptions.map(availableOption => (
      <DropdownMenu.Item
        key={`${availableOptions[0]}-${availableOption}`}
        onSelect={() => {
          onToggleOption?.(availableOption, type)
        }}
      >
        <DropdownMenu.ItemTitle>
          {capitalize(availableOption.split('_').pop())}
        </DropdownMenu.ItemTitle>
        {availableOption === chosenOption && (
          <DropdownMenu.ItemIcon iosIconName="checkmark" />
        )}
      </DropdownMenu.Item>
    ))}
  </DropdownMenu.Content>
</DropdownMenu.Root>

Dependencies

"dependencies": {
  "@react-native-masked-view/masked-view": "0.2.7",
  "@react-navigation/bottom-tabs": "^6.3.2",
  "@react-navigation/devtools": "^6.0.8",
  "@react-navigation/material-top-tabs": "^6.2.2",
  "@react-navigation/native": "^6.0.11",
  "@react-navigation/native-stack": "^6.7.0",
  "@react-navigation/stack": "^6.2.2",
  "expo": "^46.0.0-beta.6",
  "react": "18.2.0",
  "react-native": "0.69.2",
  "react-native-reanimated": "^2.9.1",
  "react-native-safe-area-context": "4.3.1",
  "react-native-screens": "~3.15.0",
  "react-native-shared-element": "^0.8.4",
  "react-navigation-shared-element": "^3.1.3",
  "zeego": "^0.4.0"
  ...
}

Cannot create wrapper around DropdownMenu.ItemIcon

Hello!

I am trying to create a reusable configuration of DropdownMenu.ItemIcon to indicate a checkbox state (I see there is DropdownMenuCheckboxItem, but we want a different look).

I've seen in the docs that I need to create a custom component, but the following doesn't seem to work.

interface DropdownMenuItemCheckIconComponentProps
    extends Omit<React.ComponentProps<typeof DropdownMenu.ItemIcon>, "ios" | "androidIconName"> {
    checked: boolean
}

export const DropdownMenuCheckIcon = DropdownMenu.create(
    ({checked, ...rest}: DropdownMenuItemCheckIconComponentProps) => {
        const theme = useTheme()

        return (
            <DropdownMenu.ItemIcon
                {...rest}
                {...(checked && {
                    ios: {
                        name: "checkmark.circle.fill" as const,
                        paletteColors: [theme.tokens.accent],
                    },
                })}
            />
        )
    },
    "ItemIcon"
)

Any ideas? :)

Dark Mode?

Is there any way to enable dark mode in Zeego? Didn't see anything about it in the docs.

CheckboxItem not displaying check icon on Android

Code

<DropdownMenuCheckboxItem
	key="test"
	textValue="TEST"
	value={true}>
	<DropdownMenu.ItemIndicator>
		<CheckmarkIcon />
	</DropdownMenu.ItemIndicator>

	<Text>TEST</Text>
</DropdownMenuCheckboxItem>

Current behavior
CheckboxItem is not displaying the check icon on Android. On iOS & web it works well

Android:
image

iOS:
image

Web:
image

Expected behavior
CheckboxItem displays the check icon on Android

Android content not respecting right margin when trigger is right aligned

When aligning the trigger to the right, the content gets opened without leaving a margin right on Android.

Code:

    <View style={{ position: "absolute", right: 0 }}>
      <DropdownMenuRoot>
        <DropdownMenuTrigger>
            <FontAwesomeIcon
              icon={faEllipsisVertical}
              color={colors.primary}
              style={{
                marginRight: 10
              }}
              size={iconSizes.xl} />
        </DropdownMenuTrigger>

        <DropdownMenuContent>
          <DropdownMenu.Sub>
            <DropdownMenu.SubTrigger
              key="language"
              textValue="Language">
            </DropdownMenu.SubTrigger>

            <DropdownMenu.SubContent>
               ....
            </DropdownMenu.SubContent>
          </DropdownMenu.Sub>

          <DropdownMenuItem
            key="help"
            textValue="Help">
          </DropdownMenuItem>
        </DropdownMenuContent>
      </DropdownMenuRoot>
    </View>

Current behavior
On the image, the content has no "native" margin right. On iOS, it does.
image

Expected behavior
Other native apps (like contacts) do have margin right when trigger is right aligned
image

** If it is left aligned, it has left margin.

Android dropdown menu improvements

Hey @nandorojo , want to preface this with some words of appreciation - really like this library so far - I think it will have a great future!

I was looking at the implementation and its awesome that you're using react-native-ios-context-menu which provides sooo many customization options. I was then looking at the Android counterpart of the native implementation and while it gets the job done, I don't think it looks nearly as pretty as the iOS one - that's for sure. A while ago I came across an Android native implementation which is very aesthetically pleasing and I think it might be worth considering to use for this project. I'm sure you're aware of the react-native-context-menu-view library - there's an open PR on their repo which proposes integrating that library. Would it be possible to explore the possibilities of using that library as the Android implementation for zeego? Paging @intergalacticspacehighway since they contributed to the Android implementation in this repository.

Any feedback is welcome. Thanks!

Icons have shrunk on iOS 17 / Xcode 15

Icons were working perfectly prior to upgrading to Xcode 15 and iOS 17. Below is a before and after of what our icons looked like:

BEFORE AFTER
266070634-a95785a1-1369-40db-abeb-adae860ee528.mov
Simulator.Screen.Recording.-.iPhone.15.Pro.-.2023-09-26.at.08.25.01.mp4

implementation:

import { Icon } from '@ntwrk1/design-system';
import React from 'react';
import { Pressable, StyleSheet, Text } from 'react-native';

import { PrimaryColorPalette } from 'assets/colors';
import * as DropdownMenu from 'zeego/dropdown-menu';

export default function CompletedShowMenu({
  onDelete,
}: {
  onDelete: () => void;
}) {
  return (
    <DropdownMenu.Root>
      <DropdownMenu.Trigger action="press">
        <Pressable style={styles.triggerButton}>
          <Icon color={PrimaryColorPalette.MAIN_1} variant="MoreVertical" />
        </Pressable>
      </DropdownMenu.Trigger>

      <DropdownMenu.Content>
        <DropdownMenu.Item
          destructive
          key="remove"
          onSelect={onDelete}
          textValue="Remove"
        >
          <DropdownMenu.ItemTitle>
            <Text>Remove</Text>
          </DropdownMenu.ItemTitle>
          <DropdownMenu.ItemIcon
            ios={{
              name: 'trash',
              pointSize: 5,
              weight: 'semibold',
              scale: 'default',
            }}
          />
        </DropdownMenu.Item>
      </DropdownMenu.Content>
    </DropdownMenu.Root>
  );
}

const styles = StyleSheet.create({
  triggerButton: {
    height: 28,
    width: 28,
    justifyContent: 'center',
    alignItems: 'center',
    borderRadius: 50,
    borderColor: PrimaryColorPalette.MAIN_5,
    borderWidth: 1,
    transform: [{ rotate: '90deg' }],
  },
});

Xcode version 15.0
Simulator: iPhone 15 Pro

How to use Trigger component as Preview

I just tried this library out and like the API quite a bit. I have been using react-native-ios-context-menu before using this library, and it allows for using the "Trigger" in this library as the "Preview" component - is this possible with this library? It seems like the Preview component is always completely separate from the Trigger component.

Edit: I'm referring to the ContextMenu component specifically.

Opinionated UI render

Fully great 👍 work, but do you think using radix is abstracting this at the wrong place? Are there plans to separate the API from the rendering?

I want to use this with react-native-web/dripsy instead of radix for the web platform.

Open dropdown menu on long press

Hello, is it possible to only open dropdown menu when long pressing the trigger? So I can have another behaviour when simply tapping.

Should we implement the `Sub` component?

It looks like Radix changed their way of making sub-menus.

Previously, to make a submenu, you would add a DropdownMenu.Root inside of an existing one. However, they now seem to use a Sub, SubTrigger, and SubContent as seen here.

I can see their reasoning here. The new API is much clearer. It's just a bit annoying to have to maintain parity, but it's probably the right move.

This is a breaking change from Radix v1, so chances are, I have to build these features before releasing zeego v1.

If anyone wants to submit a PR for these, it would be awesome. It would require:

  1. installing direct dependencies of Radix UI's dropdown/context menus into zeego
  2. adding Web/iOS/Android files for each Sub* element. Web will be easy; the others require understanding how Zeego maps children mostly.

Add custom image support

Hey there,

Thank you for the great library! I've been trying to implement a dropdown on both Android and iOS but it seems that the DropdownMenu.ItemIcon is just being ignored.
I can only get it to work if I specify iosIconName or androidIconName but I can't use my custom svg or image.

ItemImage with local source

I know that Zeego currently doesn't support remote urls with with the ItemImage component.
But is it possible to display an image with a local image source, so with an uri like assets://*?

[Android] DropdownMenu not working

Hello! Thanks for this cool library!

We just tried a small snippet from the example project and found that it only works on iOS (and maybe web), but on Android, nothing is being shown when I tap on the Trigger. I this a known issue because I see that Android is supported from the documentation? Thank you!

Repro

 <DropdownMenu.Root key={filter}>
    <DropdownMenu.Trigger>
      <ThemedChip
        key={filter}
        isSelected
        label={filter}
        style={tw('mx-2 my-2')}
        rightComponent={
          <ThemedIcon
            name="x"
            color="white"
            size={16}
            style={tw('ml-1')}
          />
        }
        // onPress={() => removeFilter(filter)}
      />
    </DropdownMenu.Trigger>
    <DropdownMenu.Content
      style={{
        minWidth: 220,
        backgroundColor: 'white',
        borderRadius: 6,
        padding: 5,
        borderWidth: 1,
        borderColor: '#fff8',
      }}
    >
      <DropdownMenuLabel>Help</DropdownMenuLabel>

      {[1, 2, 3].map(i => (
        <DropdownMenuItem key={`list-${i}`}>
          <DropdownMenuItemTitle>{`Item ${i}`}</DropdownMenuItemTitle>
        </DropdownMenuItem>
      ))}
    </DropdownMenu.Content>
  </DropdownMenu.Root>

collapse

I consulted you to provide the example code, and when it crashed on ios, I used expo 49
Exception thrown while executing UI block: *** -[__NSPlaceholderArray initWithObjects:count:]: attempt to insert nil object from objects[1]

Trigger adding extra `<View />` disrupts flex layout.

Related to #41

zeego version: 1.5.2

Trying to create a grid layout where every item has a context menu with the following code:

<Animated.ScrollView
  contentContainerStyle={{
    gap: 8,
    flexWrap: "wrap",
    flexDirection: "row",
  }}
>
  {psalmen.map(psalm => (
    <ContextMenu.Root key={psalm.nummer}>
      <ContextMenu.Trigger>
        <TouchableOpacity
          className="aspect-square grow basis-16 items-center justify-center rounded bg-tertiary/20 p-4 dark:bg-tertiary/70"
          onPress={() => onPressPsalm(psalm)}
        >
          <Text className="font-bold text-dark-blue text-2xl dark:text-white">
            {psalm.nummer}
          </Text>
        </TouchableOpacity>
      </ContextMenu.Trigger>
      <ContextMenu.Content>
        {psalm.verzen.map((vers, idx) => (
          <ContextMenu.Item
            key={`vers-${vers.nummer}-${idx}`}
            onSelect={() => onVersPress(vers)}
          >
            <ContextMenu.ItemTitle>{getVersTitle(vers, false)}</ContextMenu.ItemTitle>
            <ContextMenu.ItemIcon
              ios={{
                hierarchicalColor: "red",
                name: isFavorite(vers) ? "heart.fill" : undefined,
              }}
            />
          </ContextMenu.Item>
        ))}
      </ContextMenu.Content>
    </ContextMenu.Root>
  ))}
</Animated.ScrollView>

The result of this code is this:

Screenshots

As seen in the screenshots the items in the grid are taking up the full with of the container which is (I think) a result of <ContextMenu.Trigger /> adding an extra <View /> to the tree.

Any suggestions on how to resolve this or maybe a different approach?

Reproduction: https://github.com/Joehoel/zeego-repro

Should we add autocomplete for `iosIconName`?

The list of iOS icons is here: https://github.com/noahsark769/sfsymbols.com/blob/master/src/data/symbols.json

It would be easy to add TS autocomplete by turning that file into a union type. However, I worry that it might make the types slow.

Maybe we could do something like:

import * as DropdownMenu from 'zeego/dropdown-menu'
import { iosIconName } from 'zeego/ios-icons'

<DropdownMenu.ItemIcon iosIconName={iosIconName("xmark.circle.fill")} />

That way, you get autocomplete from iosIconName as a pure convenience feature, but it doesn't slow down TS if you don't use it. I don't know for fact this would slow it down, but with 2k + items I can only assume.

Menu.Root and Menu.Trigger breaks flex layout for trigger child

Hello again,

I'm trying to expand the child of Trigger using flex: 1 but I can't get it working.

I have the following sample code :

<View
  style={{
    display: 'flex',
    width: 300,
    height: 300,
    backgroundColor: 'red',
  }}
>
  <DropdownMenu.Root style={{ flex: 1 }}>
    <DropdownMenu.Trigger style={{ flex: 1 }}>
      <View
        style={{
          flex: 1,
          backgroundColor: 'blue',
        }}
      />
    </DropdownMenu.Trigger>
  </DropdownMenu.Root>
</View>

In such case I expect to see a blue square, but I see a red square (i.e., blue square should fill the red square, but doesn't).

If I replace DropdownMenu.Root and DropdownMenu.Trigger by View, I see the blue square.

How can I achieve this please?

Conditional items mess with keys

I'm getting a weird error. If, inside of <DropdownMenu.Content>, I have an item that is conditionally rendered, I get an error that my item keys aren't stable. This breaks it:

<Dropdown.Content>
  <Dropdown.Item key="one" />
  {false}
</Dropdown.Content>

I think it also breaks if there is an array rendered alongside a single item:

<Dropdown.Content>
  {items.map(item => <Dropdown.Item key={item} />)}
  <Dropdown.Item key="another-item" />
</Dropdown.Content>

Getting this issue on ios, will have to debug tomorrow.

Controlled closing

Hello, is there a way to control when the menu / dropdown closes?
I want to perform async operation and would like to show a loading indicator and then close the menu

Gesture conflict on Android

This is basically a duplicate of mpiannucci/react-native-context-menu-view#43

I determined that the same issue is present in this library - which means the android native implementations are most likely the same. It might be a good idea to include the information present in the issue above in the docs whenever they are released.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.