Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 20 additions & 6 deletions build/rnpm.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion build/rnpm.js.map

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion src/MenuOption.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export class MenuOption extends Component {
}

render() {
const { text, disabled, disableTouchable, children, style, testID } = this.props;
const { text, disabled, disableTouchable, children, style, testID, ...accessibilityProps } = this.props;
const customStyles = this._getCustomStyles()
if (text && React.Children.count(children) > 0) {
console.warn("MenuOption: Please don't use text property together with explicit children. Children are ignored.");
Expand Down Expand Up @@ -63,6 +63,7 @@ export class MenuOption extends Component {
testID={testID}
onPress={() => this._onSelect()}
{...defaultTouchableProps}
{...accessibilityProps}
{...customStyles.optionTouchable}
>
{rendered}
Expand All @@ -80,6 +81,9 @@ MenuOption.propTypes = {
value: PropTypes.any,
customStyles: PropTypes.object,
testID: PropTypes.string,
accessible: PropTypes.bool,
accessibilityRole: PropTypes.string,
accessibilityLabel: PropTypes.string,
};

const defaultStyles = StyleSheet.create({
Expand Down
11 changes: 9 additions & 2 deletions src/MenuTrigger.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ export class MenuTrigger extends Component {
}

render() {
const { disabled, onRef, text, children, style, customStyles = {}, menuName,
triggerOnLongPress, onAlternativeAction, testID, ...other } = this.props;
const { disabled, onRef, text, children, style, customStyles = {}, menuName,
triggerOnLongPress, onAlternativeAction, testID, accessible, accessibilityRole, accessibilityLabel, ...other } = this.props;

const onPress = () => !disabled && this._onPress();
const { Touchable, defaultTouchableProps } = makeTouchable(customStyles.TriggerTouchableComponent);
return (
Expand All @@ -25,6 +26,9 @@ export class MenuTrigger extends Component {
onPress={triggerOnLongPress ? onAlternativeAction : onPress}
onLongPress={triggerOnLongPress ? onPress : onAlternativeAction}
{...defaultTouchableProps}
accessible={accessible}
accessibilityRole={accessibilityRole}
accessibilityLabel={accessibilityLabel}
{...customStyles.triggerTouchable}
>
<View {...other} style={[customStyles.triggerWrapper, style]}>
Expand All @@ -45,6 +49,9 @@ MenuTrigger.propTypes = {
customStyles: PropTypes.object,
triggerOnLongPress: PropTypes.bool,
testID: PropTypes.string,
accessible: PropTypes.bool,
accessibilityRole: PropTypes.string,
accessibilityLabel: PropTypes.string,
};

export default withCtx(MenuTrigger)
18 changes: 13 additions & 5 deletions src/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/
declare module "react-native-popup-menu" {
import * as React from "react";
import { StyleProp, ViewStyle, TextStyle } from "react-native";
import { StyleProp, ViewStyle, TextStyle, ViewProps } from "react-native";

/**
* MenuProvider
Expand Down Expand Up @@ -88,9 +88,12 @@ declare module "react-native-popup-menu" {
triggerOnLongPress?: boolean;

onPress?(): void;
onAlternativeAction? (): void;
onAlternativeAction?(): void;
children?: React.ReactNode;
style?: StyleProp<ViewStyle>;
accessible?: ViewProps["accessible"];
accessibilityRole?: ViewProps["accessibilityRole"];
accessibilityLabel?: ViewProps["accessibilityLabel"];
}

export const MenuTrigger: React.ComponentClass<MenuTriggerProps>;
Expand Down Expand Up @@ -128,7 +131,9 @@ declare module "react-native-popup-menu" {

onSelect?(): any;
children?: React.ReactNode;
testID?: string;
accessible?: ViewProps["accessible"];
accessibilityRole?: ViewProps["accessibilityRole"];
accessibilityLabel?: ViewProps["accessibilityLabel"];
}

interface MenuOptionCustomStyle {
Expand Down Expand Up @@ -184,7 +189,10 @@ declare module "react-native-popup-menu" {
optionsLayout?: OptionsLayoutType;
}
) => void;
setOptionsCustomStyles: (name: string, optionsCustomStyles: MenuOptionsCustomStyle) => void;
setOptionsCustomStyles: (
name: string,
optionsCustomStyles: MenuOptionsCustomStyle
) => void;
getMenu: (name: string) => MenuEntry;
getAll: () => MenuEntry[];
}
Expand All @@ -199,7 +207,7 @@ declare module "react-native-popup-menu" {
toggleMenu: (name: string) => Promise<void>;
isMenuOpen: () => boolean;
}

export interface MenuContext {
// This part shouldn't be exported to the user so it's commented out
// menuRegistry: MenuRegistry;
Expand Down