{"action":"created","issue":{"url":"https://api.github.com/repos/Automattic/wp-calypso/issues/1450","labels_url":"https://api.github.com/repos/Automattic/wp-calypso/issues/1450/labels{/name}","comments_url":"https://api.github.com/repos/Automattic/wp-calypso/issues/1450/comments","events_url":"https://api.github.com/repos/Automattic/wp-calypso/issues/1450/events","html_url":"https://github.com/Automattic/wp-calypso/pull/1450","id":121368010,"number":1450,"title":"Components: Prevent <Search> from stealing the focus when typing elsewhere","user":{"login":"nylen","id":227022,"avatar_url":"https://avatars.githubusercontent.com/u/227022?v=3","gravatar_id":"","url":"https://api.github.com/users/nylen","html_url":"https://github.com/nylen","followers_url":"https://api.github.com/users/nylen/followers","following_url":"https://api.github.com/users/nylen/following{/other_user}","gists_url":"https://api.github.com/users/nylen/gists{/gist_id}","starred_url":"https://api.github.com/users/nylen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nylen/subscriptions","organizations_url":"https://api.github.com/users/nylen/orgs","repos_url":"https://api.github.com/users/nylen/repos","events_url":"https://api.github.com/users/nylen/events{/privacy}","received_events_url":"https://api.github.com/users/nylen/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/Automattic/wp-calypso/labels/Components","name":"Components","color":"006b75"},{"url":"https://api.github.com/repos/Automattic/wp-calypso/labels/Editor","name":"Editor","color":"006b75"},{"url":"https://api.github.com/repos/Automattic/wp-calypso/labels/[Status]%20Needs%20Review","name":"[Status] Needs Review","color":"fbca04"}],"state":"open","locked":false,"assignee":{"login":"nylen","id":227022,"avatar_url":"https://avatars.githubusercontent.com/u/227022?v=3","gravatar_id":"","url":"https://api.github.com/users/nylen","html_url":"https://github.com/nylen","followers_url":"https://api.github.com/users/nylen/followers","following_url":"https://api.github.com/users/nylen/following{/other_user}","gists_url":"https://api.github.com/users/nylen/gists{/gist_id}","starred_url":"https://api.github.com/users/nylen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nylen/subscriptions","organizations_url":"https://api.github.com/users/nylen/orgs","repos_url":"https://api.github.com/users/nylen/repos","events_url":"https://api.github.com/users/nylen/events{/privacy}","received_events_url":"https://api.github.com/users/nylen/received_events","type":"User","site_admin":false},"milestone":null,"comments":4,"created_at":"2015-12-09T23:44:52Z","updated_at":"2015-12-10T14:05:41Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/Automattic/wp-calypso/pulls/1450","html_url":"https://github.com/Automattic/wp-calypso/pull/1450","diff_url":"https://github.com/Automattic/wp-calypso/pull/1450.diff","patch_url":"https://github.com/Automattic/wp-calypso/pull/1450.patch"},"body":"This fixes #1389 where if the location field has user-entered text, it steals the focus back when typing into another text field:\r\n\r\n![location-steals-focus](https://cloud.githubusercontent.com/assets/227022/11676067/835a8104-9df4-11e5-8a71-edb56b576596.gif)\r\n\r\nI'm not seeing a good reason why we would want the `<Search>` component to focus itself if it has text:  in any such situation, shouldn't it already be focused?\r\n\r\nThis code or some variation of it has been present since long before OSS release.  As far as I can tell, these are the conditions needed for the bug to surface:\r\n\r\n- A `<Search>` and another text field both present on the same screen\r\n- A structure that causes `componentDidUpdate` to be called when the other text field changes (in the editor, this is the case, but I'm not entirely sure why)\r\n\r\n@aduth @mtias I saw your names a lot in the history of this component, want to take a look?"},"comment":{"url":"https://api.github.com/repos/Automattic/wp-calypso/issues/comments/163628693","html_url":"https://github.com/Automattic/wp-calypso/pull/1450#issuecomment-163628693","issue_url":"https://api.github.com/repos/Automattic/wp-calypso/issues/1450","id":163628693,"user":{"login":"rralian","id":134044,"avatar_url":"https://avatars.githubusercontent.com/u/134044?v=3","gravatar_id":"","url":"https://api.github.com/users/rralian","html_url":"https://github.com/rralian","followers_url":"https://api.github.com/users/rralian/followers","following_url":"https://api.github.com/users/rralian/following{/other_user}","gists_url":"https://api.github.com/users/rralian/gists{/gist_id}","starred_url":"https://api.github.com/users/rralian/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rralian/subscriptions","organizations_url":"https://api.github.com/users/rralian/orgs","repos_url":"https://api.github.com/users/rralian/repos","events_url":"https://api.github.com/users/rralian/events{/privacy}","received_events_url":"https://api.github.com/users/rralian/received_events","type":"User","site_admin":false},"created_at":"2015-12-10T14:05:41Z","updated_at":"2015-12-10T14:05:41Z","body":"> In my testing, loading a page with the s=test query doesn't focus the search input, not in this PR but neither in master.\r\n\r\nI'm not positive that's functionally equivalent to typing in the text field. Anyway, I can't account for a reason for this code right now and so I support removing it. This code became really complex, so could use some simplification and refactoring in general. For example, it aint great that we aren't sure why/whether this clause was ever needed."}}