-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Components: Prevent <Search> from stealing the focus when typing elsewhere #1450
Conversation
I'm not positive, but I think this had to do with search pages that append the search query as a url parameter (e.g., posts: |
In my testing, loading a page with the |
@nylen this seems like a good change, I can't figure out why we had that piece of code, it doesn't seem to be doing anything productive, and simpler code is always welcome :) If someone wanted to focus the main search in a page based on the query string it seems to me they should be explicit about it and set the autoFocus prop based on the query string. |
I'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. |
Agreed
and agreed :0 |
Components: Prevent <Search> from stealing the focus when typing elsewhere
This fixes #1389 where if the location field has user-entered text, it steals the focus back when typing into another text field:
I'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?This 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:
<Search>
and another text field both present on the same screencomponentDidUpdate
to be called when the other text field changes (in the editor, this is the case, but I'm not entirely sure why)@aduth @mtias I saw your names a lot in the history of this component, want to take a look?