Skip to content

Commit e65e933

Browse files
Add ability to pass extra props to Cancel button text in modal (#149)
1 parent f47fbe2 commit e65e933

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ Prop | Type | Optional | Default | Description
173173
`passThruProps`| object | Yes | {} | props to pass through to the container View and each option TouchableOpacity (e.g. testID for testing)
174174
`selectTextPassThruProps`| object | Yes | {} | props to pass through to the select text component
175175
`optionTextPassThruProps`| object | Yes | {} | props to pass through to the options text components in the modal
176+
`cancelTextPassThruProps`| object | Yes | {} | props to pass through to the cancel text components in the modal
176177
`scrollViewPassThruProps`| object | Yes | {} | props to pass through to the internal ScrollView
177178
`openButtonContainerAccessible`| bool | Yes | false | `true` enables accessibility for the open button container. Note: if `false` be sure to define accessibility props directly in the wrapped component.
178179
`listItemAccessible`| bool | Yes | false | `true` enables accessibility for data items. Note: data items should have an `accessibilityLabel` property if this is enabled

index.d.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,13 @@ interface IModalSelectorProps<TOption> {
308308
*/
309309
optionTextPassThruProps?: object;
310310

311+
/**
312+
* props to pass through to the cancel text components in the modal
313+
*
314+
* Default is `{}`
315+
*/
316+
cancelTextPassThruProps?: object;
317+
311318
/**
312319
* props to pass through to the internal ScrollView
313320
*

index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ const propTypes = {
6969
passThruProps: PropTypes.object,
7070
selectTextPassThruProps: PropTypes.object,
7171
optionTextPassThruProps: PropTypes.object,
72+
cancelTextPassThruProps: PropTypes.object,
7273
scrollViewPassThruProps: PropTypes.object,
7374
modalOpenerHitSlop: PropTypes.object,
7475
customSelector: PropTypes.node,
@@ -121,6 +122,7 @@ const defaultProps = {
121122
passThruProps: {},
122123
selectTextPassThruProps: {},
123124
optionTextPassThruProps: {},
125+
cancelTextPassThruProps: {},
124126
scrollViewPassThruProps: {},
125127
modalOpenerHitSlop: {top: 0, bottom: 0, left: 0, right: 0},
126128
customSelector: undefined,
@@ -309,7 +311,7 @@ export default class ModalSelector extends React.Component {
309311
<View style={[styles.cancelContainer, cancelContainerStyle]}>
310312
<TouchableOpacity onPress={this.close} activeOpacity={touchableActiveOpacity} accessible={cancelButtonAccessible} accessibilityLabel={cancelButtonAccessibilityLabel}>
311313
<View style={[styles.cancelStyle, cancelStyle]}>
312-
<Text style={[styles.cancelTextStyle,cancelTextStyle]}>{cancelText}</Text>
314+
<Text style={[styles.cancelTextStyle,cancelTextStyle]} {...this.props.cancelTextPassThruProps}>{cancelText}</Text>
313315
</View>
314316
</TouchableOpacity>
315317
</View>

0 commit comments

Comments
 (0)