Skip to content

Commit b029381

Browse files
authored
v3.7.0 #40
2 parents 19408ee + edca09f commit b029381

File tree

5 files changed

+18
-2
lines changed

5 files changed

+18
-2
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ import MaterialTabs from 'react-native-material-tabs';
6666
| onChange | none | Function | Handler that's emitted every time the user presses a tab. You can use this to change the selected index |
6767
| allowFontScaling | true | boolean | Specifies whether fonts should scale to respect Text Size accessibility settings |
6868
| uppercase | true | boolean | Specifies whether to uppercase the tab labels |
69+
| keyboardShouldPersistTaps | never | string | Specifies how the [ScrollView](https://facebook.github.io/react-native/docs/scrollview#keyboardshouldpersisttaps) should respond to taps while keyboard is open |
6970

7071
## Example
7172

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-native-material-tabs",
3-
"version": "3.6.2",
3+
"version": "3.7.0",
44
"description": "Material Design implementation of Tabs",
55
"keywords": [
66
"react",
@@ -22,7 +22,7 @@
2222
"flow": "flow check",
2323
"lint": "eslint **/*.js",
2424
"format": "eslint --fix **/*.js",
25-
"test": "jest"
25+
"test": "jest --runInBand"
2626
},
2727
"dependencies": {
2828
"prop-types": "^15.5.10",

src/__tests__/__snapshots__/main.test.js.snap

+4
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ exports[`Main should apply custom activeTextStyle to active tab 1`] = `
1717
>
1818
<RCTScrollView
1919
horizontal={true}
20+
keyboardShouldPersistTaps="never"
2021
scrollEnabled={false}
2122
showsHorizontalScrollIndicator={false}
2223
>
@@ -203,6 +204,7 @@ exports[`Main should apply custom fontFamily to tab 1`] = `
203204
>
204205
<RCTScrollView
205206
horizontal={true}
207+
keyboardShouldPersistTaps="never"
206208
scrollEnabled={false}
207209
showsHorizontalScrollIndicator={false}
208210
>
@@ -391,6 +393,7 @@ exports[`Main should display tab labels not uppercased 1`] = `
391393
>
392394
<RCTScrollView
393395
horizontal={true}
396+
keyboardShouldPersistTaps="never"
394397
scrollEnabled={false}
395398
showsHorizontalScrollIndicator={false}
396399
>
@@ -575,6 +578,7 @@ exports[`Main should render without errors 1`] = `
575578
>
576579
<RCTScrollView
577580
horizontal={true}
581+
keyboardShouldPersistTaps="never"
578582
scrollEnabled={false}
579583
showsHorizontalScrollIndicator={false}
580584
>

src/components/MaterialTabs.js

+4
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ type Props = {
2323
items: string[],
2424
uppercase: boolean,
2525
onChange: (index: number) => void,
26+
keyboardShouldPersistTaps: string,
2627
};
2728

2829
type State = {
@@ -46,6 +47,7 @@ export default class MaterialTabs extends React.Component<Props, State> {
4647
items: PropTypes.arrayOf(PropTypes.string).isRequired,
4748
uppercase: PropTypes.bool,
4849
onChange: PropTypes.func.isRequired,
50+
keyboardShouldPersistTaps: PropTypes.string,
4951
};
5052

5153
static defaultProps = {
@@ -60,6 +62,7 @@ export default class MaterialTabs extends React.Component<Props, State> {
6062
textStyle: null,
6163
uppercase: true,
6264
activeTextStyle: {},
65+
keyboardShouldPersistTaps: 'never',
6366
};
6467

6568
state = {
@@ -166,6 +169,7 @@ export default class MaterialTabs extends React.Component<Props, State> {
166169
horizontal
167170
ref={ref => (this.scrollView = ref)}
168171
showsHorizontalScrollIndicator={false}
172+
keyboardShouldPersistTaps={this.props.keyboardShouldPersistTaps}
169173
scrollEnabled={this.props.scrollable}
170174
>
171175
<TabTrack barHeight={this.props.barHeight}>

src/index.d.ts

+7
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,13 @@ interface TabsProps {
8686
* @param index
8787
*/
8888
onChange(index: number): void;
89+
90+
/**
91+
* Optional keyboard tap behaviour for the ScrollView.
92+
* See: https://facebook.github.io/react-native/docs/scrollview#keyboardshouldpersisttaps
93+
* Default 'none'.
94+
*/
95+
keyboardShouldPersistTaps?: "always" | "never" | "handled";
8996
}
9097

9198
export default class MaterialTabs extends React.Component<TabsProps> {}

0 commit comments

Comments
 (0)