{"action":"opened","number":19,"pull_request":{"url":"https://api.github.com/repos/react-navigation/react-navigation-core/pulls/19","id":229974622,"node_id":"MDExOlB1bGxSZXF1ZXN0MjI5OTc0NjIy","html_url":"https://github.com/react-navigation/react-navigation-core/pull/19","diff_url":"https://github.com/react-navigation/react-navigation-core/pull/19.diff","patch_url":"https://github.com/react-navigation/react-navigation-core/pull/19.patch","issue_url":"https://api.github.com/repos/react-navigation/react-navigation-core/issues/19","number":19,"state":"open","locked":false,"title":"[Fix RN TextInput focus bug with react-navigation] Add the node tag in navigation params after mounting a sceneview","user":{"login":"gazoudoudou","id":17501497,"node_id":"MDQ6VXNlcjE3NTAxNDk3","avatar_url":"https://avatars1.githubusercontent.com/u/17501497?v=4","gravatar_id":"","url":"https://api.github.com/users/gazoudoudou","html_url":"https://github.com/gazoudoudou","followers_url":"https://api.github.com/users/gazoudoudou/followers","following_url":"https://api.github.com/users/gazoudoudou/following{/other_user}","gists_url":"https://api.github.com/users/gazoudoudou/gists{/gist_id}","starred_url":"https://api.github.com/users/gazoudoudou/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gazoudoudou/subscriptions","organizations_url":"https://api.github.com/users/gazoudoudou/orgs","repos_url":"https://api.github.com/users/gazoudoudou/repos","events_url":"https://api.github.com/users/gazoudoudou/events{/privacy}","received_events_url":"https://api.github.com/users/gazoudoudou/received_events","type":"User","site_admin":false},"body":"I noticed a bug while using react-navigation + the react-native TextInput component.\r\n\r\nHOW TO REPRODUCE THE BUG :\r\n\r\nLet’s consider the following app with only 2 pages :\r\n\r\nPage1.js :\r\n`import React, { PureComponent } from 'react';\r\nimport { TouchableOpacity, View, Text } from 'react-native';\r\n\r\nexport default class Page1 extends PureComponent {\r\n  render() {\r\n    return (\r\n      <View>\r\n        <TouchableOpacity\r\n          style={{ backgroundColor: 'red', height: 30, justifyContent: 'center', alignItems: 'center' }}\r\n          onPress={() => this.props.navigation.navigate('Page2')}\r\n        >\r\n          <Text>Go to page 2</Text>\r\n        </TouchableOpacity>\r\n      </View>\r\n    );\r\n  }\r\n}`\r\n\r\nPage2.js :\r\n`import React, { PureComponent } from 'react';\r\nimport { TouchableOpacity, TextInput, Keyboard, View, Text } from 'react-native';\r\n\r\nexport default class Page2 extends PureComponent {\r\n  componentDidMount() {\r\n    this.textInput && this.textInput.focus();\r\n  }\r\n\r\n  render() {\r\n    return (\r\n      <View>\r\n        <TextInput ref={ref => (this.textInput = ref)} placeholder={'Write something here'} />\r\n        <TouchableOpacity\r\n          style={{ backgroundColor: 'blue', height: 30, marginTop: 20, justifyContent: 'center', alignItems: 'center' }}\r\n          onPress={Keyboard.dismiss}\r\n        >\r\n          <Text>Dismiss keyboard</Text>\r\n        </TouchableOpacity>\r\n      </View>\r\n    );\r\n  }\r\n}`\r\n\r\nApp.js :\r\n`import React, { Component } from 'react';\r\nimport { createStackNavigator, createAppContainer } from 'react-navigation';\r\nimport * as Pages from './pages';\r\n\r\nconst RootNavigator = createStackNavigator(\r\n  {\r\n    Page1: {\r\n      screen: Pages.Page1,\r\n    },\r\n    Page2: {\r\n      screen: Pages.Page2,\r\n    },\r\n  },\r\n  {\r\n    initialRouteName: 'Page1',\r\n  }\r\n);\r\n\r\nconst AppContainer = createAppContainer(RootNavigator);\r\n\r\nclass App extends Component {\r\n  render() {\r\n    return <AppContainer />;\r\n  }\r\n}\r\n\r\nexport default App;`\r\n\r\nOn Page1 you have a single button to navigate to Page2. On Page2, you’d like that a TextInput is focused when you arrive on this page. You also have a « dismiss » button to close de keyboard when the textinput is focused.\r\n\r\nYou could use the TextInput props « autoFocus » so that it is focused at the beginning. There is absolutely no bug in this case.\r\nBut instead, I tried to create a ref « textinput » for the TextInput component, and called this.textinput.focus() in the componentDidMount method to focus it at the beginning. It works, but in this case, when I click on the dismiss button, the keyboard won’t close.\r\n\r\nAfter digging, I found that a blur call is made when you arrive on Page2, coming from the @react-navigation/native/src/KeyboardAwareNavigator.js file. In _handleTransitionStart, transitionProps.index !== prevTransitionProps.index is true because you are switching pages, and !!currentField too in the « this.textinput.focus() » case. As a consequence, it blurs the textinput, the TextInput.State.currentlyFocusedField() becomes null, and you cannot dismiss the keyboard anymore.\r\n\r\nMy fix :\r\n\r\nI tried to add another condition than the if(currentField) when we should blur the currently focused textinput. According to me, it should be something like if(currentField && previousPage includes currentField) or if(currentField && currentPage does not include currentField)\r\n\r\nTo do so, I used the viewIsDescendantOf method from UIManager, react-native. In addition to the tag of the currently focused field (which is precisely currentField), I needed the tag of the previous scene, which may be its parent.\r\n\r\nThis is what I did in this PR","created_at":"2018-11-11T20:05:52Z","updated_at":"2018-11-11T20:05:52Z","closed_at":null,"merged_at":null,"merge_commit_sha":null,"assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/react-navigation/react-navigation-core/pulls/19/commits","review_comments_url":"https://api.github.com/repos/react-navigation/react-navigation-core/pulls/19/comments","review_comment_url":"https://api.github.com/repos/react-navigation/react-navigation-core/pulls/comments{/number}","comments_url":"https://api.github.com/repos/react-navigation/react-navigation-core/issues/19/comments","statuses_url":"https://api.github.com/repos/react-navigation/react-navigation-core/statuses/c91417515b3114cb9593c1e15e2fb0c3444ccd13","head":{"label":"gazoudoudou:add/nodeTag-nav-param-when-mount-a-sceneview","ref":"add/nodeTag-nav-param-when-mount-a-sceneview","sha":"c91417515b3114cb9593c1e15e2fb0c3444ccd13","user":{"login":"gazoudoudou","id":17501497,"node_id":"MDQ6VXNlcjE3NTAxNDk3","avatar_url":"https://avatars1.githubusercontent.com/u/17501497?v=4","gravatar_id":"","url":"https://api.github.com/users/gazoudoudou","html_url":"https://github.com/gazoudoudou","followers_url":"https://api.github.com/users/gazoudoudou/followers","following_url":"https://api.github.com/users/gazoudoudou/following{/other_user}","gists_url":"https://api.github.com/users/gazoudoudou/gists{/gist_id}","starred_url":"https://api.github.com/users/gazoudoudou/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gazoudoudou/subscriptions","organizations_url":"https://api.github.com/users/gazoudoudou/orgs","repos_url":"https://api.github.com/users/gazoudoudou/repos","events_url":"https://api.github.com/users/gazoudoudou/events{/privacy}","received_events_url":"https://api.github.com/users/gazoudoudou/received_events","type":"User","site_admin":false},"repo":{"id":157086022,"node_id":"MDEwOlJlcG9zaXRvcnkxNTcwODYwMjI=","name":"react-navigation-core","full_name":"gazoudoudou/react-navigation-core","private":false,"owner":{"login":"gazoudoudou","id":17501497,"node_id":"MDQ6VXNlcjE3NTAxNDk3","avatar_url":"https://avatars1.githubusercontent.com/u/17501497?v=4","gravatar_id":"","url":"https://api.github.com/users/gazoudoudou","html_url":"https://github.com/gazoudoudou","followers_url":"https://api.github.com/users/gazoudoudou/followers","following_url":"https://api.github.com/users/gazoudoudou/following{/other_user}","gists_url":"https://api.github.com/users/gazoudoudou/gists{/gist_id}","starred_url":"https://api.github.com/users/gazoudoudou/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gazoudoudou/subscriptions","organizations_url":"https://api.github.com/users/gazoudoudou/orgs","repos_url":"https://api.github.com/users/gazoudoudou/repos","events_url":"https://api.github.com/users/gazoudoudou/events{/privacy}","received_events_url":"https://api.github.com/users/gazoudoudou/received_events","type":"User","site_admin":false},"html_url":"https://github.com/gazoudoudou/react-navigation-core","description":"Core utilities for the react-navigation framework","fork":true,"url":"https://api.github.com/repos/gazoudoudou/react-navigation-core","forks_url":"https://api.github.com/repos/gazoudoudou/react-navigation-core/forks","keys_url":"https://api.github.com/repos/gazoudoudou/react-navigation-core/keys{/key_id}","collaborators_url":"https://api.github.com/repos/gazoudoudou/react-navigation-core/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/gazoudoudou/react-navigation-core/teams","hooks_url":"https://api.github.com/repos/gazoudoudou/react-navigation-core/hooks","issue_events_url":"https://api.github.com/repos/gazoudoudou/react-navigation-core/issues/events{/number}","events_url":"https://api.github.com/repos/gazoudoudou/react-navigation-core/events","assignees_url":"https://api.github.com/repos/gazoudoudou/react-navigation-core/assignees{/user}","branches_url":"https://api.github.com/repos/gazoudoudou/react-navigation-core/branches{/branch}","tags_url":"https://api.github.com/repos/gazoudoudou/react-navigation-core/tags","blobs_url":"https://api.github.com/repos/gazoudoudou/react-navigation-core/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/gazoudoudou/react-navigation-core/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/gazoudoudou/react-navigation-core/git/refs{/sha}","trees_url":"https://api.github.com/repos/gazoudoudou/react-navigation-core/git/trees{/sha}","statuses_url":"https://api.github.com/repos/gazoudoudou/react-navigation-core/statuses/{sha}","languages_url":"https://api.github.com/repos/gazoudoudou/react-navigation-core/languages","stargazers_url":"https://api.github.com/repos/gazoudoudou/react-navigation-core/stargazers","contributors_url":"https://api.github.com/repos/gazoudoudou/react-navigation-core/contributors","subscribers_url":"https://api.github.com/repos/gazoudoudou/react-navigation-core/subscribers","subscription_url":"https://api.github.com/repos/gazoudoudou/react-navigation-core/subscription","commits_url":"https://api.github.com/repos/gazoudoudou/react-navigation-core/commits{/sha}","git_commits_url":"https://api.github.com/repos/gazoudoudou/react-navigation-core/git/commits{/sha}","comments_url":"https://api.github.com/repos/gazoudoudou/react-navigation-core/comments{/number}","issue_comment_url":"https://api.github.com/repos/gazoudoudou/react-navigation-core/issues/comments{/number}","contents_url":"https://api.github.com/repos/gazoudoudou/react-navigation-core/contents/{+path}","compare_url":"https://api.github.com/repos/gazoudoudou/react-navigation-core/compare/{base}...{head}","merges_url":"https://api.github.com/repos/gazoudoudou/react-navigation-core/merges","archive_url":"https://api.github.com/repos/gazoudoudou/react-navigation-core/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/gazoudoudou/react-navigation-core/downloads","issues_url":"https://api.github.com/repos/gazoudoudou/react-navigation-core/issues{/number}","pulls_url":"https://api.github.com/repos/gazoudoudou/react-navigation-core/pulls{/number}","milestones_url":"https://api.github.com/repos/gazoudoudou/react-navigation-core/milestones{/number}","notifications_url":"https://api.github.com/repos/gazoudoudou/react-navigation-core/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/gazoudoudou/react-navigation-core/labels{/name}","releases_url":"https://api.github.com/repos/gazoudoudou/react-navigation-core/releases{/id}","deployments_url":"https://api.github.com/repos/gazoudoudou/react-navigation-core/deployments","created_at":"2018-11-11T14:11:24Z","updated_at":"2018-11-11T14:11:26Z","pushed_at":"2018-11-11T16:23:43Z","git_url":"git://github.com/gazoudoudou/react-navigation-core.git","ssh_url":"git@github.com:gazoudoudou/react-navigation-core.git","clone_url":"https://github.com/gazoudoudou/react-navigation-core.git","svn_url":"https://github.com/gazoudoudou/react-navigation-core","homepage":null,"size":482,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"react-navigation:master","ref":"master","sha":"403698ae493d3b8645c946d9aa94ee1839398fa9","user":{"login":"react-navigation","id":29647600,"node_id":"MDEyOk9yZ2FuaXphdGlvbjI5NjQ3NjAw","avatar_url":"https://avatars2.githubusercontent.com/u/29647600?v=4","gravatar_id":"","url":"https://api.github.com/users/react-navigation","html_url":"https://github.com/react-navigation","followers_url":"https://api.github.com/users/react-navigation/followers","following_url":"https://api.github.com/users/react-navigation/following{/other_user}","gists_url":"https://api.github.com/users/react-navigation/gists{/gist_id}","starred_url":"https://api.github.com/users/react-navigation/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/react-navigation/subscriptions","organizations_url":"https://api.github.com/users/react-navigation/orgs","repos_url":"https://api.github.com/users/react-navigation/repos","events_url":"https://api.github.com/users/react-navigation/events{/privacy}","received_events_url":"https://api.github.com/users/react-navigation/received_events","type":"Organization","site_admin":false},"repo":{"id":152654118,"node_id":"MDEwOlJlcG9zaXRvcnkxNTI2NTQxMTg=","name":"react-navigation-core","full_name":"react-navigation/react-navigation-core","private":false,"owner":{"login":"react-navigation","id":29647600,"node_id":"MDEyOk9yZ2FuaXphdGlvbjI5NjQ3NjAw","avatar_url":"https://avatars2.githubusercontent.com/u/29647600?v=4","gravatar_id":"","url":"https://api.github.com/users/react-navigation","html_url":"https://github.com/react-navigation","followers_url":"https://api.github.com/users/react-navigation/followers","following_url":"https://api.github.com/users/react-navigation/following{/other_user}","gists_url":"https://api.github.com/users/react-navigation/gists{/gist_id}","starred_url":"https://api.github.com/users/react-navigation/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/react-navigation/subscriptions","organizations_url":"https://api.github.com/users/react-navigation/orgs","repos_url":"https://api.github.com/users/react-navigation/repos","events_url":"https://api.github.com/users/react-navigation/events{/privacy}","received_events_url":"https://api.github.com/users/react-navigation/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/react-navigation/react-navigation-core","description":"Core utilities for the react-navigation framework","fork":false,"url":"https://api.github.com/repos/react-navigation/react-navigation-core","forks_url":"https://api.github.com/repos/react-navigation/react-navigation-core/forks","keys_url":"https://api.github.com/repos/react-navigation/react-navigation-core/keys{/key_id}","collaborators_url":"https://api.github.com/repos/react-navigation/react-navigation-core/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/react-navigation/react-navigation-core/teams","hooks_url":"https://api.github.com/repos/react-navigation/react-navigation-core/hooks","issue_events_url":"https://api.github.com/repos/react-navigation/react-navigation-core/issues/events{/number}","events_url":"https://api.github.com/repos/react-navigation/react-navigation-core/events","assignees_url":"https://api.github.com/repos/react-navigation/react-navigation-core/assignees{/user}","branches_url":"https://api.github.com/repos/react-navigation/react-navigation-core/branches{/branch}","tags_url":"https://api.github.com/repos/react-navigation/react-navigation-core/tags","blobs_url":"https://api.github.com/repos/react-navigation/react-navigation-core/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/react-navigation/react-navigation-core/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/react-navigation/react-navigation-core/git/refs{/sha}","trees_url":"https://api.github.com/repos/react-navigation/react-navigation-core/git/trees{/sha}","statuses_url":"https://api.github.com/repos/react-navigation/react-navigation-core/statuses/{sha}","languages_url":"https://api.github.com/repos/react-navigation/react-navigation-core/languages","stargazers_url":"https://api.github.com/repos/react-navigation/react-navigation-core/stargazers","contributors_url":"https://api.github.com/repos/react-navigation/react-navigation-core/contributors","subscribers_url":"https://api.github.com/repos/react-navigation/react-navigation-core/subscribers","subscription_url":"https://api.github.com/repos/react-navigation/react-navigation-core/subscription","commits_url":"https://api.github.com/repos/react-navigation/react-navigation-core/commits{/sha}","git_commits_url":"https://api.github.com/repos/react-navigation/react-navigation-core/git/commits{/sha}","comments_url":"https://api.github.com/repos/react-navigation/react-navigation-core/comments{/number}","issue_comment_url":"https://api.github.com/repos/react-navigation/react-navigation-core/issues/comments{/number}","contents_url":"https://api.github.com/repos/react-navigation/react-navigation-core/contents/{+path}","compare_url":"https://api.github.com/repos/react-navigation/react-navigation-core/compare/{base}...{head}","merges_url":"https://api.github.com/repos/react-navigation/react-navigation-core/merges","archive_url":"https://api.github.com/repos/react-navigation/react-navigation-core/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/react-navigation/react-navigation-core/downloads","issues_url":"https://api.github.com/repos/react-navigation/react-navigation-core/issues{/number}","pulls_url":"https://api.github.com/repos/react-navigation/react-navigation-core/pulls{/number}","milestones_url":"https://api.github.com/repos/react-navigation/react-navigation-core/milestones{/number}","notifications_url":"https://api.github.com/repos/react-navigation/react-navigation-core/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/react-navigation/react-navigation-core/labels{/name}","releases_url":"https://api.github.com/repos/react-navigation/react-navigation-core/releases{/id}","deployments_url":"https://api.github.com/repos/react-navigation/react-navigation-core/deployments","created_at":"2018-10-11T20:49:23Z","updated_at":"2018-11-11T16:37:15Z","pushed_at":"2018-11-10T17:12:53Z","git_url":"git://github.com/react-navigation/react-navigation-core.git","ssh_url":"git@github.com:react-navigation/react-navigation-core.git","clone_url":"https://github.com/react-navigation/react-navigation-core.git","svn_url":"https://github.com/react-navigation/react-navigation-core","homepage":null,"size":481,"stargazers_count":30,"watchers_count":30,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":11,"mirror_url":null,"archived":false,"open_issues_count":6,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":11,"open_issues":6,"watchers":30,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/react-navigation/react-navigation-core/pulls/19"},"html":{"href":"https://github.com/react-navigation/react-navigation-core/pull/19"},"issue":{"href":"https://api.github.com/repos/react-navigation/react-navigation-core/issues/19"},"comments":{"href":"https://api.github.com/repos/react-navigation/react-navigation-core/issues/19/comments"},"review_comments":{"href":"https://api.github.com/repos/react-navigation/react-navigation-core/pulls/19/comments"},"review_comment":{"href":"https://api.github.com/repos/react-navigation/react-navigation-core/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/react-navigation/react-navigation-core/pulls/19/commits"},"statuses":{"href":"https://api.github.com/repos/react-navigation/react-navigation-core/statuses/c91417515b3114cb9593c1e15e2fb0c3444ccd13"}},"author_association":"NONE","merged":false,"mergeable":null,"rebaseable":null,"mergeable_state":"unknown","merged_by":null,"comments":0,"review_comments":0,"maintainer_can_modify":true,"commits":1,"additions":5,"deletions":0,"changed_files":1}}
{"actor":{"display_login":"gazoudoudou"}}