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

Add onLongPress event for picker button #152

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ Prop | Type | Optional | Default | Description
`onDropdownWillShow`| func | Yes | | Trigger when dropdown will show by touching the button. **Return `false` can cancel the event.**
`onDropdownWillHide`| func | Yes | | Trigger when dropdown will hide by touching the button. **Return `false` can cancel the event.**
`onSelect` | func | Yes | | Trigger when option row touched with selected `index` and `value`. **Return `false` can cancel the event.**
`onLongPress` | func | Yes | | Trigger when the button has received `onLongPress` event
`accessible` | bool | Yes | true | Set accessibility of dropdown modal and dropdown rows
`keyboardShouldPersistTaps` | enum('always', 'never', 'handled') | Yes | 'never' | See react-native `ScrollView` props

Expand Down
7 changes: 7 additions & 0 deletions components/ModalDropdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ export default class ModalDropdown extends Component {
disabled={disabled}
accessible={accessible}
onPress={this._onButtonPress}
onLongPress={this._onButtonLongPress}
>
{
children ||
Expand All @@ -196,6 +197,12 @@ export default class ModalDropdown extends Component {
}
};

_onButtonLongPress = () => {
if (this.props.onLongPress) {
this.props.onLongPress();
}
}

_renderModal() {
const {animated, accessible, dropdownStyle} = this.props;
const {showDropdown, loading} = this.state;
Expand Down