-
Notifications
You must be signed in to change notification settings - Fork 20
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
Drive initial search from URL query string #83
Conversation
search.focus(); | ||
var activeEl = document.activeElement; | ||
if (activeEl && search.el.contains(activeEl)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this if
necessary?
document.activeElement
is always truthysearch.el.contains(activeEl)
should always be true as you're callingsearch.focus()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this
if
necessary?
It's a stylistic thing IMHO. If the maintainers dislike it, I'm fine with changing it.
document.activeElement
is always truthy
Usually but not always, e.g. document.activeElement
can be null
, at least in IE while the page is initially loading. You're right in that it should be a non-issue if search.focus()
does its job, though.
search.el.contains(activeEl)
should always be true as you're callingsearch.focus()
True based on the application-level view of things but that is dependent on the current function of the various components being pieced together. It may be over-cautious but it certainly isn't invalid.
shrugs
Like I said, I'm fine with changing whatever makes this get merged. 😛
why was |
It wasn't, GitHub just doesn't want to show the diff because there are too many changes. |
haha oops :p |
The other approach I had in mind would eliminate all of this // In "boot/index.js":
var initialQuery = qs.parse(location.search).q || '';
search.input(initialQuery);
search.show(initialQuery); // In "search/index.js":
SearchView.prototype.input = function(query) {
this.el.querySelector('input').value = query;
}; |
+1 to |
OK, will do. |
Fixes #82 Also now auto-focuses into the Search box on load.
Amended. Other new changes worth noting:
|
thanks. Have no time this week, but I will check it next week or maybe someone else :) |
Drive initial search from URL query string
🤘 |
Fixes #82