Compare commits

...

9 Commits

Author SHA1 Message Date
Satyajit Sahoo
1406eb83ed chore: publish
- @react-navigation/stack@5.12.8
2020-11-21 05:32:53 +01:00
Satyajit Sahoo
3e069b718d fix: force dismiss keyboard if there was no gesture
closes #9078
2020-11-21 05:32:00 +01:00
Satyajit Sahoo
7754eb450f chore: publish
- @react-navigation/bottom-tabs@5.11.2
 - @react-navigation/compat@5.3.10
 - @react-navigation/core@5.14.4
 - @react-navigation/devtools@5.1.18
 - @react-navigation/drawer@5.11.4
 - @react-navigation/material-bottom-tabs@5.3.10
 - @react-navigation/material-top-tabs@5.3.10
 - @react-navigation/native@5.8.10
 - @react-navigation/stack@5.12.7
2020-11-20 18:07:07 +01:00
Satyajit Sahoo
95b2599877 fix: fix incorrect state change events in independent nested container
fixes #9080
2020-11-20 18:06:35 +01:00
Satyajit Sahoo
efcfa7121f chore: only match repo links for GitHub in action 2020-11-20 12:03:50 +01:00
Satyajit Sahoo
a8e27ef448 chore: fix typo in github workflow 2020-11-16 15:33:46 +01:00
Satyajit Sahoo
946d2923d7 chore: publish
- @react-navigation/drawer@5.11.3
2020-11-16 02:01:44 +01:00
Satyajit Sahoo
794339eeed fix: hide drawer's header by default 2020-11-16 02:00:05 +01:00
Satyajit Sahoo
53141a6436 chore: add action to check for repro 2020-11-14 20:53:56 +01:00
27 changed files with 297 additions and 54 deletions

42
.github/workflows/check-repro.yml vendored Normal file
View File

@@ -0,0 +1,42 @@
name: Check for repro
on:
issues:
types: [opened, edited]
issue_comment:
types: [created, edited]
jobs:
check-repro:
runs-on: ubuntu-latest
steps:
- uses: actions/github-script@v2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const body = context.payload.comment
? context.payload.comment.body
: context.payload.issue.body
if (!/https?:\/\/((github\.com\/[^/]+\/[^/]+\/?[\s\n]+)|(snack\.expo\.io\/.+))/gm.test(body)) {
return
}
await github.issues.addLabels({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
labels: ['repro provided'],
})
try {
await github.issues.removeLabel({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
name: 'needs repro',
})
} catch (error) {
if (!/Label does not exist/.test(error.message)) {
throw error
}
}

View File

@@ -291,6 +291,7 @@ export default function App() {
{() => (
<Drawer.Navigator
drawerType={isLargeScreen ? 'permanent' : undefined}
screenOptions={{ headerShown: true }}
>
<Drawer.Screen
name="Examples"

View File

@@ -3,6 +3,14 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [5.11.2](https://github.com/react-navigation/react-navigation/compare/@react-navigation/bottom-tabs@5.11.1...@react-navigation/bottom-tabs@5.11.2) (2020-11-20)
**Note:** Version bump only for package @react-navigation/bottom-tabs
## [5.11.1](https://github.com/react-navigation/react-navigation/compare/@react-navigation/bottom-tabs@5.11.0...@react-navigation/bottom-tabs@5.11.1) (2020-11-10)
**Note:** Version bump only for package @react-navigation/bottom-tabs

View File

@@ -1,7 +1,7 @@
{
"name": "@react-navigation/bottom-tabs",
"description": "Bottom tab navigator following iOS design guidelines",
"version": "5.11.1",
"version": "5.11.2",
"keywords": [
"react-native-component",
"react-component",
@@ -41,7 +41,7 @@
},
"devDependencies": {
"@react-native-community/bob": "^0.16.2",
"@react-navigation/native": "^5.8.9",
"@react-navigation/native": "^5.8.10",
"@testing-library/react-native": "^7.1.0",
"@types/color": "^3.0.1",
"@types/react": "^16.9.53",

View File

@@ -3,6 +3,14 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [5.3.10](https://github.com/react-navigation/react-navigation/compare/@react-navigation/compat@5.3.9...@react-navigation/compat@5.3.10) (2020-11-20)
**Note:** Version bump only for package @react-navigation/compat
## [5.3.9](https://github.com/react-navigation/react-navigation/compare/@react-navigation/compat@5.3.8...@react-navigation/compat@5.3.9) (2020-11-10)
**Note:** Version bump only for package @react-navigation/compat

View File

@@ -1,7 +1,7 @@
{
"name": "@react-navigation/compat",
"description": "Compatibility layer to write navigator definitions in static configuration format",
"version": "5.3.9",
"version": "5.3.10",
"license": "MIT",
"repository": {
"type": "git",
@@ -32,7 +32,7 @@
},
"devDependencies": {
"@react-native-community/bob": "^0.16.2",
"@react-navigation/native": "^5.8.9",
"@react-navigation/native": "^5.8.10",
"@types/react": "^16.9.53",
"react": "~16.13.1",
"typescript": "^4.0.3"

View File

@@ -3,6 +3,17 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [5.14.4](https://github.com/react-navigation/react-navigation/compare/@react-navigation/core@5.14.3...@react-navigation/core@5.14.4) (2020-11-20)
### Bug Fixes
* fix incorrect state change events in independent nested container ([95b2599](https://github.com/react-navigation/react-navigation/commit/95b2599877f5ceedf753e399e0586bb4af54cb87)), closes [#9080](https://github.com/react-navigation/react-navigation/issues/9080)
## [5.14.3](https://github.com/react-navigation/react-navigation/compare/@react-navigation/core@5.14.2...@react-navigation/core@5.14.3) (2020-11-10)

View File

@@ -1,7 +1,7 @@
{
"name": "@react-navigation/core",
"description": "Core utilities for building navigators",
"version": "5.14.3",
"version": "5.14.4",
"keywords": [
"react",
"react-native",

View File

@@ -8,9 +8,11 @@ import {
NavigationAction,
} from '@react-navigation/routers';
import EnsureSingleNavigator from './EnsureSingleNavigator';
import UnhandledActionContext from './UnhandledActionContext';
import NavigationBuilderContext from './NavigationBuilderContext';
import NavigationStateContext from './NavigationStateContext';
import UnhandledActionContext from './UnhandledActionContext';
import NavigationRouteContext from './NavigationRouteContext';
import NavigationContext from './NavigationContext';
import { ScheduleUpdateContext } from './useScheduleUpdate';
import useChildListeners from './useChildListeners';
import useKeyedChildListeners from './useKeyedChildListeners';
@@ -397,7 +399,7 @@ const BaseNavigationContainer = React.forwardRef(
[]
);
return (
let element = (
<ScheduleUpdateContext.Provider value={scheduleContext}>
<NavigationBuilderContext.Provider value={builderContext}>
<NavigationStateContext.Provider value={context}>
@@ -410,6 +412,19 @@ const BaseNavigationContainer = React.forwardRef(
</NavigationBuilderContext.Provider>
</ScheduleUpdateContext.Provider>
);
if (independent) {
// We need to clear any existing contexts for nested independent container to work correctly
element = (
<NavigationRouteContext.Provider value={undefined}>
<NavigationContext.Provider value={undefined}>
{element}
</NavigationContext.Provider>
</NavigationRouteContext.Provider>
);
}
return element;
}
);

View File

@@ -757,3 +757,67 @@ it('invokes the unhandled action listener with the unhandled action', () => {
type: 'NAVIGATE',
});
});
it('works with state change events in independent nested container', () => {
const TestNavigator = (props: any) => {
const { state, descriptors } = useNavigationBuilder(MockRouter, props);
return (
<React.Fragment>
{state.routes.map((route) => descriptors[route.key].render())}
</React.Fragment>
);
};
const ref = React.createRef<NavigationContainerRef>();
const onStateChange = jest.fn();
render(
<BaseNavigationContainer>
<TestNavigator>
<Screen name="foo">
{() => (
<BaseNavigationContainer
independent
ref={ref}
onStateChange={onStateChange}
>
<TestNavigator>
<Screen name="qux">{() => null}</Screen>
<Screen name="lex">{() => null}</Screen>
</TestNavigator>
</BaseNavigationContainer>
)}
</Screen>
<Screen name="bar">{() => null}</Screen>
</TestNavigator>
</BaseNavigationContainer>
);
act(() => ref.current?.navigate('lex'));
expect(onStateChange).toBeCalledWith({
index: 1,
key: '15',
routeNames: ['qux', 'lex'],
routes: [
{ key: 'qux', name: 'qux' },
{ key: 'lex', name: 'lex' },
],
stale: false,
type: 'test',
});
expect(ref.current?.getRootState()).toEqual({
index: 1,
key: '15',
routeNames: ['qux', 'lex'],
routes: [
{ key: 'qux', name: 'qux' },
{ key: 'lex', name: 'lex' },
],
stale: false,
type: 'test',
});
});

View File

@@ -3,6 +3,14 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [5.1.18](https://github.com/react-navigation/react-navigation/compare/@react-navigation/devtools@5.1.17...@react-navigation/devtools@5.1.18) (2020-11-20)
**Note:** Version bump only for package @react-navigation/devtools
## [5.1.17](https://github.com/react-navigation/react-navigation/compare/@react-navigation/devtools@5.1.16...@react-navigation/devtools@5.1.17) (2020-11-10)
**Note:** Version bump only for package @react-navigation/devtools

View File

@@ -1,7 +1,7 @@
{
"name": "@react-navigation/devtools",
"description": "Developer tools for React Navigation",
"version": "5.1.17",
"version": "5.1.18",
"keywords": [
"react",
"react-native",
@@ -36,7 +36,7 @@
"clean": "del lib"
},
"dependencies": {
"@react-navigation/core": "^5.14.3",
"@react-navigation/core": "^5.14.4",
"deep-equal": "^2.0.4"
},
"devDependencies": {

View File

@@ -3,6 +3,25 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [5.11.4](https://github.com/react-navigation/react-navigation/compare/@react-navigation/drawer@5.11.3...@react-navigation/drawer@5.11.4) (2020-11-20)
**Note:** Version bump only for package @react-navigation/drawer
## [5.11.3](https://github.com/react-navigation/react-navigation/compare/@react-navigation/drawer@5.11.2...@react-navigation/drawer@5.11.3) (2020-11-16)
### Bug Fixes
* hide drawer's header by default ([794339e](https://github.com/react-navigation/react-navigation/commit/794339eeed7c0d3b0e8b1752e494fbb4608ddfad))
## [5.11.2](https://github.com/react-navigation/react-navigation/compare/@react-navigation/drawer@5.11.1...@react-navigation/drawer@5.11.2) (2020-11-10)
**Note:** Version bump only for package @react-navigation/drawer

View File

@@ -1,7 +1,7 @@
{
"name": "@react-navigation/drawer",
"description": "Drawer navigator component with animated transitions and gesturess",
"version": "5.11.2",
"version": "5.11.4",
"keywords": [
"react-native-component",
"react-component",
@@ -46,7 +46,7 @@
},
"devDependencies": {
"@react-native-community/bob": "^0.16.2",
"@react-navigation/native": "^5.8.9",
"@react-navigation/native": "^5.8.10",
"@testing-library/react-native": "^7.1.0",
"@types/react": "^16.9.53",
"@types/react-native": "^0.63.30",

View File

@@ -176,7 +176,7 @@ export default function DrawerView({
const {
header = (props: DrawerHeaderProps) => <Header {...props} />,
headerShown = true,
headerShown = false,
} = descriptor.options;
return (

View File

@@ -3,6 +3,14 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [5.3.10](https://github.com/react-navigation/react-navigation/compare/@react-navigation/material-bottom-tabs@5.3.9...@react-navigation/material-bottom-tabs@5.3.10) (2020-11-20)
**Note:** Version bump only for package @react-navigation/material-bottom-tabs
## [5.3.9](https://github.com/react-navigation/react-navigation/compare/@react-navigation/material-bottom-tabs@5.3.8...@react-navigation/material-bottom-tabs@5.3.9) (2020-11-10)
**Note:** Version bump only for package @react-navigation/material-bottom-tabs

View File

@@ -1,7 +1,7 @@
{
"name": "@react-navigation/material-bottom-tabs",
"description": "Integration for bottom navigation component from react-native-paper",
"version": "5.3.9",
"version": "5.3.10",
"keywords": [
"react-native-component",
"react-component",
@@ -42,7 +42,7 @@
},
"devDependencies": {
"@react-native-community/bob": "^0.16.2",
"@react-navigation/native": "^5.8.9",
"@react-navigation/native": "^5.8.10",
"@testing-library/react-native": "^7.1.0",
"@types/react": "^16.9.53",
"@types/react-native": "^0.63.30",

View File

@@ -3,6 +3,14 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [5.3.10](https://github.com/react-navigation/react-navigation/compare/@react-navigation/material-top-tabs@5.3.9...@react-navigation/material-top-tabs@5.3.10) (2020-11-20)
**Note:** Version bump only for package @react-navigation/material-top-tabs
## [5.3.9](https://github.com/react-navigation/react-navigation/compare/@react-navigation/material-top-tabs@5.3.8...@react-navigation/material-top-tabs@5.3.9) (2020-11-10)
**Note:** Version bump only for package @react-navigation/material-top-tabs

View File

@@ -1,7 +1,7 @@
{
"name": "@react-navigation/material-top-tabs",
"description": "Integration for the animated tab view component from react-native-tab-view",
"version": "5.3.9",
"version": "5.3.10",
"keywords": [
"react-native-component",
"react-component",
@@ -45,7 +45,7 @@
},
"devDependencies": {
"@react-native-community/bob": "^0.16.2",
"@react-navigation/native": "^5.8.9",
"@react-navigation/native": "^5.8.10",
"@testing-library/react-native": "^7.1.0",
"@types/react": "^16.9.53",
"@types/react-native": "^0.63.30",

View File

@@ -3,6 +3,14 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [5.8.10](https://github.com/react-navigation/react-navigation/compare/@react-navigation/native@5.8.9...@react-navigation/native@5.8.10) (2020-11-20)
**Note:** Version bump only for package @react-navigation/native
## [5.8.9](https://github.com/react-navigation/react-navigation/compare/@react-navigation/native@5.8.8...@react-navigation/native@5.8.9) (2020-11-10)
**Note:** Version bump only for package @react-navigation/native

View File

@@ -1,7 +1,7 @@
{
"name": "@react-navigation/native",
"description": "React Native integration for React Navigation",
"version": "5.8.9",
"version": "5.8.10",
"keywords": [
"react-native",
"react-navigation",
@@ -37,7 +37,7 @@
"clean": "del lib"
},
"dependencies": {
"@react-navigation/core": "^5.14.3",
"@react-navigation/core": "^5.14.4",
"escape-string-regexp": "^4.0.0",
"nanoid": "^3.1.15"
},

View File

@@ -3,6 +3,25 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [5.12.8](https://github.com/react-navigation/react-navigation/compare/@react-navigation/stack@5.12.7...@react-navigation/stack@5.12.8) (2020-11-21)
### Bug Fixes
* force dismiss keyboard if there was no gesture ([3e069b7](https://github.com/react-navigation/react-navigation/commit/3e069b718d60f5381957f2d3838ee04ee9384779)), closes [#9078](https://github.com/react-navigation/react-navigation/issues/9078)
## [5.12.7](https://github.com/react-navigation/react-navigation/compare/@react-navigation/stack@5.12.6...@react-navigation/stack@5.12.7) (2020-11-20)
**Note:** Version bump only for package @react-navigation/stack
## [5.12.6](https://github.com/react-navigation/react-navigation/compare/@react-navigation/stack@5.12.5...@react-navigation/stack@5.12.6) (2020-11-10)

View File

@@ -1,7 +1,7 @@
{
"name": "@react-navigation/stack",
"description": "Stack navigator component for iOS and Android with animated transitions and gestures",
"version": "5.12.6",
"version": "5.12.8",
"keywords": [
"react-native-component",
"react-component",
@@ -46,7 +46,7 @@
"devDependencies": {
"@react-native-community/bob": "^0.16.2",
"@react-native-community/masked-view": "^0.1.10",
"@react-navigation/native": "^5.8.9",
"@react-navigation/native": "^5.8.10",
"@testing-library/react-native": "^7.1.0",
"@types/color": "^3.0.1",
"@types/react": "^16.9.53",

View File

@@ -1,15 +1,17 @@
import * as React from 'react';
import { TextInput, Platform, Keyboard } from 'react-native';
import { TextInput, Keyboard, HostComponent } from 'react-native';
type Props = {
enabled: boolean;
children: (props: {
onPageChangeStart: () => void;
onPageChangeConfirm: () => void;
onPageChangeConfirm: (force: boolean) => void;
onPageChangeCancel: () => void;
}) => React.ReactNode;
};
type InputRef = React.ElementRef<HostComponent<unknown>> | undefined;
export default class KeyboardManager extends React.Component<Props> {
componentWillUnmount() {
this.clearKeyboardTimeout();
@@ -17,7 +19,7 @@ export default class KeyboardManager extends React.Component<Props> {
// Numeric id of the previously focused text input
// When a gesture didn't change the tab, we can restore the focused input with this
private previouslyFocusedTextInput: any | null = null;
private previouslyFocusedTextInput: InputRef = undefined;
private startTimestamp: number = 0;
private keyboardTimeout: any;
@@ -35,7 +37,8 @@ export default class KeyboardManager extends React.Component<Props> {
this.clearKeyboardTimeout();
const input: any = TextInput.State.currentlyFocusedInput
// @ts-expect-error: blurTextInput accepts both number and ref, but types say only ref
const input: InputRef = TextInput.State.currentlyFocusedInput
? TextInput.State.currentlyFocusedInput()
: TextInput.State.currentlyFocusedField();
@@ -49,25 +52,30 @@ export default class KeyboardManager extends React.Component<Props> {
this.startTimestamp = Date.now();
};
private handlePageChangeConfirm = () => {
private handlePageChangeConfirm = (force: boolean) => {
if (!this.props.enabled) {
return;
}
this.clearKeyboardTimeout();
const input = this.previouslyFocusedTextInput;
if (force) {
// Always dismiss input, even if we don't have a ref to it
// We might not have the ref if onPageChangeStart was never called
// This can happen if page change was not from a gesture
Keyboard.dismiss();
} else {
const input = this.previouslyFocusedTextInput;
if (input) {
if (Platform.OS === 'android') {
Keyboard.dismiss();
} else {
if (input) {
// Dismiss the keyboard only if an input was a focused before
// This makes sure we don't dismiss input on going back and focusing an input
TextInput.State.blurTextInput(input);
}
}
// Cleanup the ID on successful page change
this.previouslyFocusedTextInput = null;
this.previouslyFocusedTextInput = undefined;
};
private handlePageChangeCancel = () => {
@@ -91,11 +99,11 @@ export default class KeyboardManager extends React.Component<Props> {
if (Date.now() - this.startTimestamp < 100) {
this.keyboardTimeout = setTimeout(() => {
TextInput.State.focusTextInput(input);
this.previouslyFocusedTextInput = null;
this.previouslyFocusedTextInput = undefined;
}, 100);
} else {
TextInput.State.focusTextInput(input);
this.previouslyFocusedTextInput = null;
this.previouslyFocusedTextInput = undefined;
}
}
};

View File

@@ -41,7 +41,7 @@ type Props = ViewProps & {
gestureDirection: GestureDirection;
onOpen: () => void;
onClose: () => void;
onTransitionStart?: (props: { closing: boolean }) => void;
onTransition?: (props: { closing: boolean; gesture: boolean }) => void;
onGestureBegin?: () => void;
onGestureCanceled?: () => void;
onGestureEnd?: () => void;
@@ -178,7 +178,7 @@ export default class Card extends React.Component<Props> {
transitionSpec,
onOpen,
onClose,
onTransitionStart,
onTransition,
} = this.props;
const toValue = this.getAnimateToValue({
@@ -198,7 +198,7 @@ export default class Card extends React.Component<Props> {
clearTimeout(this.pendingGestureCallback);
onTransitionStart?.({ closing });
onTransition?.({ closing, gesture: velocity !== undefined });
animation(gesture, {
...spec.config,
velocity,

View File

@@ -46,7 +46,7 @@ type Props = TransitionPreset & {
) => void;
onTransitionEnd?: (props: { route: Route<string> }, closing: boolean) => void;
onPageChangeStart?: () => void;
onPageChangeConfirm?: () => void;
onPageChangeConfirm?: (force: boolean) => void;
onPageChangeCancel?: () => void;
onGestureStart?: (props: { route: Route<string> }) => void;
onGestureEnd?: (props: { route: Route<string> }) => void;
@@ -116,42 +116,58 @@ function CardContainer({
scene,
transitionSpec,
}: Props) {
React.useEffect(() => {
onPageChangeConfirm?.();
}, [active, onPageChangeConfirm]);
const handleOpen = () => {
onTransitionEnd?.({ route: scene.route }, false);
onOpenRoute({ route: scene.route });
const { route } = scene;
onTransitionEnd?.({ route }, false);
onOpenRoute({ route });
};
const handleClose = () => {
onTransitionEnd?.({ route: scene.route }, true);
onCloseRoute({ route: scene.route });
const { route } = scene;
onTransitionEnd?.({ route }, true);
onCloseRoute({ route });
};
const handleGestureBegin = () => {
const { route } = scene;
onPageChangeStart?.();
onGestureStart?.({ route: scene.route });
onGestureStart?.({ route });
};
const handleGestureCanceled = () => {
const { route } = scene;
onPageChangeCancel?.();
onGestureCancel?.({ route: scene.route });
onGestureCancel?.({ route });
};
const handleGestureEnd = () => {
onGestureEnd?.({ route: scene.route });
const { route } = scene;
onGestureEnd?.({ route });
};
const handleTransitionStart = ({ closing }: { closing: boolean }) => {
if (active && closing) {
onPageChangeConfirm?.();
const handleTransition = ({
closing,
gesture,
}: {
closing: boolean;
gesture: boolean;
}) => {
const { route } = scene;
if (!gesture) {
onPageChangeConfirm?.(true);
} else if (active && closing) {
onPageChangeConfirm?.(false);
} else {
onPageChangeCancel?.();
}
onTransitionStart?.({ route: scene.route }, closing);
onTransitionStart?.({ route }, closing);
};
const insets = {
@@ -201,7 +217,7 @@ function CardContainer({
overlay={cardOverlay}
overlayEnabled={cardOverlayEnabled}
shadowEnabled={cardShadowEnabled}
onTransitionStart={handleTransitionStart}
onTransition={handleTransition}
onGestureBegin={handleGestureBegin}
onGestureCanceled={handleGestureCanceled}
onGestureEnd={handleGestureEnd}

View File

@@ -65,7 +65,7 @@ type Props = {
) => void;
onTransitionEnd: (props: { route: Route<string> }, closing: boolean) => void;
onPageChangeStart?: () => void;
onPageChangeConfirm?: () => void;
onPageChangeConfirm?: (force: boolean) => void;
onPageChangeCancel?: () => void;
onGestureStart?: (props: { route: Route<string> }) => void;
onGestureEnd?: (props: { route: Route<string> }) => void;