Giter Club home page Giter Club logo

react-native-menu's Introduction

react-native-menu

A menu component for Android and iOS that provides a dropdown similar to Android's Spinner, but does not retain a persistent selection.

The API is very flexible so you are free to extend the styling and behaviour.

Installation

$ npm install react-native-menu --save

Or with yarn:

$ yarn add react-native-menu

Demo

iOS Android

Basic Usage

import React, { View, Text, AppRegistry } from 'react-native';
import Menu, { MenuContext, MenuOptions, MenuOption, MenuTrigger } from 'react-native-menu';

const App = () => (
  // You need to place a MenuContext somewhere in your application, usually at the root.
  // Menus will open within the context, and only one menu can open at a time per context.
  <MenuContext style={{ flex: 1 }}>
    <TopNavigation/>
    <View style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}><Text>Hello!</Text></View>
  </MenuContext>
);

const TopNavigation = () => (
  <View style={{ padding: 10, flexDirection: 'row', backgroundColor: 'pink' }}>
    <View style={{ flex: 1 }}><Text>My App</Text></View>
    <Menu onSelect={(value) => alert(`User selected the number ${value}`)}>
      <MenuTrigger>
        <Text style={{ fontSize: 20 }}>&#8942;</Text>
      </MenuTrigger>
      <MenuOptions>
        <MenuOption value={1}>
          <Text>One</Text>
        </MenuOption>
        <MenuOption value={2}>
          <Text>Two</Text>
        </MenuOption>
      </MenuOptions>
    </Menu>
  </View>
);

AppRegistry.registerComponent('Example', () => App);

Important: In order for the <Menu/> to work, you need to mount <MenuContext/> as an ancestor to <Menu/>. This allows the menu to open on top of all other components mounted under <MenuContext/> -- basically, the menu will be moved to be the last child of the context.

You must also have a <MenuTrigger/> and a <MenuOptions/> as direct children under <Menu/>. The MenuTrigger component opens the menu when pressed. The MenuOptions component can take any children, but you need at least one MenuOption child in order for the menu to actually do anything.

The MenuOption component can take any children.

Please refer to the full working example here.

Adding feedback to MenuTrigger and MenuOption components

By default, the MenuTrigger and MenuOption components render with a TouchableWithoutFeedback component, however this may make the menu feel unnatural in your app.

To override this, both components will take a renderTouchable property, which should be a function which returns an alternate component to use. For example:

import { TouchableOpacity, Text } from 'react-native';
import Menu, { MenuOptions, MenuOption, MenuTrigger } from 'react-native-menu';

const renderTouchable = () => <TouchableOpacity/>;

const menu = () => (
  <Menu>
    <MenuTrigger renderTouchable={renderTouchable}>
      <Text>Trigger</Text>
    </MenuTrigger>
    <MenuOptions>
      <MenuOption value={1} renderTouchable={renderTouchable}>
        <Text>One</Text>
      </MenuOption>
      <MenuOption value={2} renderTouchable={renderTouchable}>
        <Text>Two</Text>
      </MenuOption>
    </MenuOptions>
  </Menu>
);

API

MenuContext

Methods:

  • isMenuOpen() -- Returns true if menu is open
  • openMenu() -- Opens the menu
  • closeMenu() -- Closes the menu
  • toggleMenu() -- Toggle the menu between open and close

Props:

  • 'detectBackHandler' -- If true, menu context detects an Android hardware back press, closes menu and stops it from propagating and potentially causing bugs. (Default: true)
  • style -- Overrides default style properties (user-defined style will take priority)
  • onCloseMenu -- Handler that will be called with the state of MenuContext, if defined.

Menu

Methods:

  • getName() -- Returns the menu name (e.g. useful to get auto generated name)

Props:

  • onSelect -- This function is called with the value the MenuOption that has been selected by the user

MenuTrigger

Props:

  • disabled -- If true, then this trigger is not pressable
  • style -- Overrides default style properties (user-defined style will take priority)
  • renderTouchable -- A function which can override the default TouchableWithoutFeedback component by returning a different component. See an example here.

MenuOptions

Props:

  • optionsContainerStyle -- Provides custom styling for options container
  • renderOptionsContainer -- A function that renders takes in the MenuOptions element and renders a container element that contains the options. Default function wraps options with a ScrollView.

For example, if you want to change the options width to 300, you can use <MenuOptions optionsContainerStyle={{ width: 300 }}>. To further customize the rendered content you can do something like <MenuOptions renderOptionsContainer={(options) => <SomeCustomContainer>{options}</SomeCustomContainer>}>.

MenuOption

Props:

  • disabled -- If true, then this option is not selectable
  • style -- Overrides default style properties (user-defined style will take priority)
  • renderTouchable -- A function which can override the default TouchableWithoutFeedback component by returning a different component. See an example here.

Latest Changes

0.23.0

  • Compatible with latest react-native version. Thanks to all the people who submitted a PR! (@amensouissi, SkipperEl)

0.20.1

0.20.0

  • Fixes compatibility with React Native 0.27.2 (thanks @Froelund)

0.19.0

  • Fixes a performance issue where registering menu options on already rendered and opened menu causes infinite render loop (Closes #5, #9).

0.18.15

  • Fixes issue where multiple unnamed Menu components under one `MenuContext causes bad positioning.

0.18.14

  • Lazily calculate menu position on open -- fixes stale calculation issues.

Roadmap

Features

  • Allow positioning of menu to be customized (currently only anchors to top-right of Menu).
  • Detect if the menu will be rendered off-screen, and adjust positioning accordingly.

Testing

Install dev modules:

yarn

Run unit tests

yarn test:unit

Run integration tests

Make sure you have a connected android device. You find list devices using adb devices.

yarn test:integration

Contributing

Contributions are welcome! Just open an issues with any ideas or pull-requests. I will take a look when I have time. :)

react-native-menu's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

react-native-menu's Issues

Accessibility of menu items

I work on test automatization and menu items are not accessible and can't be inspected using Appium inspector.

Cannot read property 'makeName' of undefined.

My sample code

import Menu, {
MenuContext,
MenuOptions,
MenuOption,
MenuTrigger
} from "react-native-menu";
import React, { Component } from "react";
import { Text, TouchableOpacity } from "react-native";

import Button from "./Button";
const renderTouchable = () => ;

export default class Gmenu extends Component {
render() {
return (



Trigger



One


Two



);
}
}

Parts of Dropdown Displaying Off-Screen

I believe I am using react-native-menu version 0.21.0. Unfortunately, in my ScrollView when the option button is pressed for an item that is toward the bottom of the scene, it causes parts of the menu to render outside of the viewport. See image:

img_0383-modified

How do you guys handle this? I wanted to get the position of the menu upon rendering but I do not seem to be able to do this (tried using onLayout), that way maybe I could adjust the positioning of the menu. I tried to get the positioning of the list item but it renders right away, before the user starts scrolling, so the initial positioning doesn't come in handy.

Do you guys have a way to avoid having the menu render outside of the viewport in these cases?

Missed demo

Hello!
As it is UI component image absence is very discouraging.

2018-03-07_12-03-23

Using Image as Trigger for the PopUp Menu

I am trying to populate menu on click of Image Button. I am unable to wrap Trigger on Image component. Is Trigger work only for with texts?

image

Code Snippet



import React, { Component } from 'react';
import {
  AppRegistry,
  StyleSheet,
  Text,
  View,
  TouchableOpacity,Image,
  Dimensions
} from 'react-native';

import Menu, { MenuContext, MenuOptions, MenuOption, MenuTrigger } from 'react-native-menu';

export default class MenuButton extends Component {
  render() {
    return (
      <MenuContext  style={styles.container}>
        <Text style={styles.welcome}>
          React Native Context Menu!
        </Text>
    

        <Menu onSelect={(value) => alert(`User selected the number ${value}`)}>
     <MenuTrigger>
       <Text style={{ fontSize: 20 }}>&#8942;</Text>
     </MenuTrigger>
     <MenuOptions>
       <MenuOption value={1}>
         <Text>One</Text>
       </MenuOption>
       <MenuOption value={2}>
         <Text>Two</Text>
       </MenuOption>
     </MenuOptions>
   </Menu>

        <TouchableOpacity

                 style={{ backgroundColor: '#673ab7',
                          borderWidth:1,
                          borderColor:'rgba(0,0,0,0.2)',
                          alignItems:'center',
                          justifyContent:'center',
                          width:50,
                          height:50,
                          position: 'absolute',
                          right: 50,
                          bottom:50,
                          zIndex: 1000,
                          borderRadius:100,
                       }}>

                       <Image
                       source={require('./src/assets/menu.png')}
                       style={{width: 30,
                          height: 30}}>
                       </Image>
        </TouchableOpacity>
      </MenuContext >
    );
  }
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
    backgroundColor: '#F5FCFF',
  },
  welcome: {
    fontSize: 20,
    textAlign: 'center',
    margin: 10,
  },
  instructions: {
    textAlign: 'center',
    color: '#333333',
    marginBottom: 5,
  },
});

AppRegistry.registerComponent('MenuButton', () => MenuButton);'''

Android: Needs manual installation instructions

Installation instructions are missing the other 4 steps required to install this library into a react-native app.

Step 1.) npm i react-native-menu --save
This step only creates ./node_modules/react-native-menu. Library is not built. Library is not linked. Library is not initialized in an android app.

Missing steps:
Step 2.) Modify ./android/settings.gradle
usually something like append to project inclusion list:

include ':name-of-library-goes-here'
project('name-of-library-goes-here').projectDir = new File(settingsDir, '../node_modules/name-of-library-goes-here')

Step 3.) Modify ./android/app/build.gradle
usually something like append to dependencies:

compile project(':name-of-library-goes-here')

Step 4.) Modify ./android/app/src/AndroidManifest.xml
If this project needs additional permission scopes, write down an example AndroidManifest.xml with the added permission scope included.

Step 5.) Modify ./android/app/src/main/java/PATH/TO/YOUR/MainApplication.java
Initialize the built library here; usually something like:

import com.jaysoo.RNMenu;
...
something, something, some Java code {
return Arrays.asList(
...,
new RNMenu()
)
}

===================================
Current project installation leaves us in the dark. Example project uses the source code in the same project so it's not helpful in showing us what the project inclusion files should look like.

Otherwise, library's demo GIF looks nice, wish we can actually use the library though.

Doesn't re-render onLayout

Having a hard time following the code, but it seems like whatever it's going on with measurement and layout doesn't happen when you rotate the device (and subsequently trigger an layout event that's supposed to be handled by onLayout. I've noticed this is set to be only called once, but this isn't the issue as it happens if I remove this line as well.
The resulting problem is that the open menu's width is calculated fine on render, but if I rotate the device then the menu is no longer full width as I've set it to be.

Menu throws an error after latest upgrade (RN 0.44)

I have recently upgraded my React Native to the latest version (0.44) which seems to have broken this component.
Just including something as basic as <Menu></Menu> would give the following:

`undefined is not an object (evaluating 'this.context.menuController.makeName')

Menu_componentWillMount
makeMenu.js:34:66
measureLifeCyclePerf
ReactCompositeComponent.js:63:11
mountComponent
ReactCompositeComponent.js:322:10
mountComponent
ReactReconciler.js:57:6
mountChildren
ReactMultiChild.js:277:10
initializeChildren
ReactNativeBaseComponent.js:67:41
mountComponent
ReactNativeBaseComponent.js:173:6
mountComponent
ReactReconciler.js:57:6
performInitialMount
ReactCompositeComponent.js:516:6
mountComponent
ReactCompositeComponent.js:347:8
mountComponent
ReactReconciler.js:57:6
mountChildren
ReactMultiChild.js:277:10
initializeChildren
ReactNativeBaseComponent.js:67:41
mountComponent
ReactNativeBaseComponent.js:173:6
mountComponent
ReactReconciler.js:57:6
performInitialMount
ReactCompositeComponent.js:516:6
mountComponent
ReactCompositeComponent.js:347:8
mountComponent
ReactReconciler.js:57:6
performInitialMount
ReactCompositeComponent.js:516:6
mountComponent
ReactCompositeComponent.js:347:8
mountComponent
ReactReconciler.js:57:6
performInitialMount
ReactCompositeComponent.js:516:6
mountComponent
ReactCompositeComponent.js:347:8
mountComponent
ReactReconciler.js:57:6
mountChildren
ReactMultiChild.js:277:10
initializeChildren
ReactNativeBaseComponent.js:67:41
mountComponent
ReactNativeBaseComponent.js:173:6
mountComponent
ReactReconciler.js:57:6
performInitialMount
ReactCompositeComponent.js:516:6
mountComponent
ReactCompositeComponent.js:347:8
mountComponent
ReactReconciler.js:57:6
performInitialMount
ReactCompositeComponent.js:516:6
mountComponent
ReactCompositeComponent.js:347:8
mountComponent
ReactReconciler.js:57:6
performInitialMount
ReactCompositeComponent.js:516:6
mountComponent
ReactCompositeComponent.js:347:8
mountComponent
ReactReconciler.js:57:6
performInitialMount
ReactCompositeComponent.js:516:6
mountComponent
ReactCompositeComponent.js:347:8
mountComponent
ReactReconciler.js:57:6
mountChildren
ReactMultiChild.js:277:10
initializeChildren
ReactNativeBaseComponent.js:67:41
mountComponent
ReactNativeBaseComponent.js:173:6
mountComponent
ReactReconciler.js:57:6
performInitialMount
ReactCompositeComponent.js:516:6
mountComponent
ReactCompositeComponent.js:347:8
mountComponent
ReactReconciler.js:57:6
mountChildren
ReactMultiChild.js:277:10
initializeChildren
ReactNativeBaseComponent.js:67:41
mountComponent
ReactNativeBaseComponent.js:173:6
mountComponent
ReactReconciler.js:57:6
performInitialMount
ReactCompositeComponent.js:516:6
mountComponent
ReactCompositeComponent.js:347:8
mountComponent
ReactReconciler.js:57:6
performInitialMount
ReactCompositeComponent.js:516:6
mountComponent
ReactCompositeComponent.js:347:8
mountComponent
ReactReconciler.js:57:6
mountChildren
ReactMultiChild.js:277:10
initializeChildren
ReactNativeBaseComponent.js:67:41
mountComponent
ReactNativeBaseComponent.js:173:6
mountComponent
ReactReconciler.js:57:6
performInitialMount
ReactCompositeComponent.js:516:6
mountComponent
ReactCompositeComponent.js:347:8
mountComponent
ReactReconciler.js:57:6
performInitialMount
ReactCompositeComponent.js:516:6
mountComponent
ReactCompositeComponent.js:347:8
mountComponent
ReactReconciler.js:57:6
performInitialMount
ReactCompositeComponent.js:516:6
mountComponent
ReactCompositeComponent.js:347:8
mountComponent
ReactReconciler.js:57:6
performInitialMount
ReactCompositeComponent.js:516:6
mountComponent
ReactCompositeComponent.js:347:8
mountComponent
ReactReconciler.js:57:6
performInitialMount
ReactCompositeComponent.js:516:6
mountComponent
ReactCompositeComponent.js:347:8
mountComponent
ReactReconciler.js:57:6
performInitialMount
ReactCompositeComponent.js:516:6
mountComponent
ReactCompositeComponent.js:347:8
mountComponent
ReactReconciler.js:57:6
performInitialMount
ReactCompositeComponent.js:516:6
mountComponent
ReactCompositeComponent.js:347:8
mountComponent
ReactReconciler.js:57:6
updateChildren
ReactChildReconciler.js:165:10
_reconcilerUpdateChildren
ReactMultiChild.js:223:10
_updateChildren
ReactMultiChild.js:366:6
updateChildren
ReactMultiChild.js:352:25
receiveComponent
ReactNativeBaseComponent.js:118:24
receiveComponent
ReactReconciler.js:158:38
_updateRenderedComponentWithNextElement
ReactCompositeComponent.js:1140:8
_updateRenderedComponent
ReactCompositeComponent.js:1111:6
_performComponentUpdate
ReactCompositeComponent.js:1032:36
updateComponent
ReactCompositeComponent.js:915:8
receiveComponent
ReactCompositeComponent.js:745:6
receiveComponent
ReactReconciler.js:158:38
updateChildren
ReactChildReconciler.js:142:10
_reconcilerUpdateChildren
ReactMultiChild.js:223:10
_updateChildren
ReactMultiChild.js:366:6
updateChildren
ReactMultiChild.js:352:25
receiveComponent
ReactNativeBaseComponent.js:118:24
receiveComponent
ReactReconciler.js:158:38
_updateRenderedComponentWithNextElement
ReactCompositeComponent.js:1140:8
_updateRenderedComponent
ReactCompositeComponent.js:1111:6
_performComponentUpdate
ReactCompositeComponent.js:1032:36
updateComponent
ReactCompositeComponent.js:915:8
receiveComponent
ReactCompositeComponent.js:745:6
receiveComponent
ReactReconciler.js:158:38
_updateRenderedComponentWithNextElement
ReactCompositeComponent.js:1140:8
_updateRenderedComponent
ReactCompositeComponent.js:1111:6
_performComponentUpdate
ReactCompositeComponent.js:1032:36
updateComponent
ReactCompositeComponent.js:915:8
receiveComponent
ReactCompositeComponent.js:745:6
receiveComponent
ReactReconciler.js:158:38
_updateRenderedComponentWithNextElement
ReactCompositeComponent.js:1140:8
_updateRenderedComponent
ReactCompositeComponent.js:1111:6
_performComponentUpdate
ReactCompositeComponent.js:1032:36
updateComponent
ReactCompositeComponent.js:915:8
receiveComponent
ReactCompositeComponent.js:745:6
receiveComponent
ReactReconciler.js:158:38
updateChildren
ReactChildReconciler.js:142:10
_reconcilerUpdateChildren
ReactMultiChild.js:223:10
_updateChildren
ReactMultiChild.js:366:6
updateChildren
ReactMultiChild.js:352:25
receiveComponent
ReactNativeBaseComponent.js:118:24
receiveComponent
ReactReconciler.js:158:38
_updateRenderedComponentWithNextElement
ReactCompositeComponent.js:1140:8
_updateRenderedComponent
ReactCompositeComponent.js:1111:6
_performComponentUpdate
ReactCompositeComponent.js:1032:36
updateComponent
ReactCompositeComponent.js:915:8
receiveComponent
ReactCompositeComponent.js:745:6
receiveComponent
ReactReconciler.js:158:38
_updateRenderedComponentWithNextElement
ReactCompositeComponent.js:1140:8
_updateRenderedComponent
ReactCompositeComponent.js:1111:6
_performComponentUpdate
ReactCompositeComponent.js:1032:36
updateComponent
ReactCompositeComponent.js:915:8
performUpdateIfNecessary
ReactCompositeComponent.js:770:8
performUpdateIfNecessary
ReactReconciler.js:210:46
runBatchedUpdates
ReactUpdates.js:146:6
perform
Transaction.js:150:24
perform
Transaction.js:150:24
flushBatchedUpdates
ReactUpdates.js:164:24
closeAll
Transaction.js:221:29
perform
Transaction.js:163:24
batchedUpdatesWithControlledComponents
ReactGenericBatching.js:51:26
_receiveRootNodeIDEvent
ReactNativeEventEmitter.js:105:40
receiveEvent
ReactNativeEventEmitter.js:131:6
__callFunction
MessageQueue.js:250:47

MessageQueue.js:101:26
__guard
MessageQueue.js:218:6
callFunctionReturnFlushedQueue
MessageQueue.js:100:17
`

Any thought on this issue?

Cannot read property 'measure' makeMenuContext.js

I am testing my application in a browser so far. In my phone works sweet. Nevertheless I am using a react-web-native dependencie. I have some problems with this statement:
NativeModules: { UIManager }
The method that is not found is UIManager.measure
I want to know what does exactly do this method? Also I would like to know if you won't have any problem to help me in that task?

menu not positioned correctly

Hi,

When using components that slide in, the menu appears in the wrong location. looking into this, it is relying on px, py of the component. In my case the component slides in from the side so the px is wrong.

thanks

Add some margin to the right

It would be great if there was a way to add some space to the right of the MenuOptions. It doesn't look good when the menu is hugging the side of the screen.

Screenshots

Hi there,

Is there any screenshots of how this looks for Android and on iOS? That's the first thing I look for before deciding to dig furhter.

Component updated every 16ms.

setState in MenuContext, which is called using controller when Menu is updated refresh the state again, which ends in a infinite loop of setState.

TouchableOpacity inside MenuTrigger

I would like my trigger to dim when pressed, like a normal button. But it seems that this breaks react-native-menu. Is there any official way to do this?

It would be great if MenuTrigger could include this as a default option, because I think most people would it expect it to work this way. (When you press the trigger, the UI needs to show some feedback.)

Menu not position correctly

image

I'm using react-native-router-flux to toggle between app scenes, after a transition when I try to click on the toggle menu is displayed offscreen at the opposite side (left instead of right)

Any idea or advice? I've tried various combinations of flex layouts on MenuContext and Menu but no luck.

Combining with ListView

Hi,
I'd like to combine the menu functionality with listview, to make the menu look like a context menu.
I tried to get started with your example, here's the relevant code:

<MenuContext style={{ flex: 1 }}>
    <ListView
    ref="listview"
    key={"postList"}
    dataSource={this.state.dataSource}
    renderSectionHeader={this.renderSectionHeader}
    renderRow={this.renderArticle}
        />
</MenuContext>

And the renderArticle function code:

<View style={styles.articleView}>
    <View style={styles.articleViewMeta}>
        <Text style={styles.articleViewMetaTitle}>{article.title}</Text>
        <View style={{flex: 1, flexDirection: 'row', justifyContent: 'space-between'}}>
            <View style={{ padding: 10, flexDirection: 'row', backgroundColor: 'pink' }}>

                <Menu onSelect={(value) => alert(`User selected the number ${value}`)}>
                <MenuTrigger>
                    <Text style={{ fontSize: 20 }}>&#8942;</Text>
                </MenuTrigger>
                <MenuOptions>
                    <MenuOption value={1}>
                    <Text>One</Text>
                    </MenuOption>
                    <MenuOption value={2}>
                    <Text>Two</Text>
                    </MenuOption>
                </MenuOptions>
                </Menu>
            </View>
            <Text style={styles.articleViewMetaAuthor}>{article.author}</Text>
        </View>
    </View>
    <Image source={{uri: article.image}} style={styles.articleViewImage} />
</View>

I can see the MenuTrigger on the right place, but I can't see the menu when pressing on the trigger.
Any suggestions?

undefined is not a object ( evaluating '_react.propstype.array')

By using
import ModalPicker from 'react-native-modal-picker'
giving error
undefined is not a object ( evaluating '_react.propstype.array')
my react version is
"react": "16.0.0-alpha.12",
"react-native": "0.46.4",
"react-native-modal-picker": "0.0.16",

my class have this code

constructor() {
super();

    this.state = {
        textInputValue: ''
    }
}

render() {
    let index = 0;
    const data = [
        { key: index++, section: true, label: 'Fruits' },
        { key: index++, label: 'Red Apples' },
        { key: index++, label: 'Cherries' },
        { key: index++, label: 'Cranberries' },
        { key: index++, label: 'Pink Grapefruit' },
        { key: index++, label: 'Raspberries' },
        { key: index++, section: true, label: 'Vegetables' },
        { key: index++, label: 'Beets' },

{ key: index++, label: 'Red Peppers' },
{ key: index++, label: 'Radishes' },
{ key: index++, label: 'Radicchio' },
{ key: index++, label: 'Red Onions' },
{ key: index++, label: 'Red Potatoes' },
{ key: index++, label: 'Rhubarb' },
{ key: index++, label: 'Tomatoes' }
];

    return (
        <View style={{flex:1, justifyContent:'space-around', padding:50}}>

            <ModalPicker
                data={data}
                initValue="Select something yummy!"
                onChange={(option)=>{ alert(`${option.label} (${option.key}) nom nom nom`) }} />

            <ModalPicker
                data={data}
                initValue="Select something yummy!"

onChange={(option)=>{ this.setState({textInputValue:option.label})}}>

                <TextInput
                    style={{borderWidth:1, borderColor:'#ccc', padding:10, height:30}}
                    editable={false}
                    placeholder="Select something yummy!"
                    value={this.state.textInputValue} />
                    
            </ModalPicker>

MenuOptions to inherit MenuTrigger's width

Hi,
I want a behaviour such that the MenuOptions looks as if it naturally follows the MenuTrigger. kinda like this:
screenshot 2016-10-13 19 05 23

My MenuTrigger's width is determined by its parent View so it stretches across it, but I can't figure out an elegant way to make MenuOptions use that same width.
What I currently have is this:
screenshot 2016-10-13 19 07 02

Anyone got an idea?

Thanks!
IY

Edge detection: avoiding screen overflow

I really like this component. However, if you use on a component that is close to the left edge of the screen, the dropdown will overflow the screen.

The expected behaviour in this case would be that the dropdown would behave more like a "long press" context menu, and appear over the trigger in a way that displays the entire menu visibly.

MenuTrigger sometimes does not work

Is this version stable? because I tried to click the MenuTrigger in dropdown and sometimes it shows MenuOptions and sometimes it does not show. It is just way too random. Sometimes even a reload (without changes on the code) can make the MenuTrigger not showing the MenuOptions. How to debug?

Menu shows up behind Modal

Hi,

I'm trying to implement the context menu in a Modal. I find that when I click the trigger, the options menu appears behind the modal for some reason.

High CPU consumption while menu is opened

CPU usage (reported by simulator) is near to 100% when the menu is opened even though there is no other activity (neither user activity nor "animation in progress").

In my application logs I can see that the applications keep re-rendering. (I have MenuContext at the application root as advised in documentation).

Another note: I can observe small lag between clicking of MenuTrigger and till the menu is opened. Might or might not be related to suboptimal CPU consumption.

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.