-
Notifications
You must be signed in to change notification settings - Fork 16
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
Improved keyboard usability #5
base: master
Are you sure you want to change the base?
Conversation
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.
instead of passing key event into doLookup return deferred and add callback to it, otherwise doLookup gains new responsibility that has nothing to do with doing lokup
Something like this? |
Sort of, but then all returns in doLookup need to return deferred, otherwise empty input results in error
But perhaps Another thing I noticed in your version clearing input no longer clears the content. I think it should. While you're at it, Escape would be a useful shortcut to clear and focus word input field. |
But then there's either nothing to activate, or worse, the old top result. Typing Btw, everything feels a lot spiffier when you reduce the timeout to, say, 100ms (which would also slightly alleviate missed Enter problems as a side effect, but the deferred solution is much, much better).
Oh, I thought that was unintentional. I find it rather disorienting and it's downward counterproductive if you want to look up something in a currently open article.
Cheers. |
You can make the same argument about your
Don't exaggerate. You don't "wait, wait, wait". You just wait :)
Then I don't understand what is the purpose of this. If the purpose is to break the wait and force it to do lookup - it doesn't do that. It actually cancels previously scheduled lookup, makes you wait for debounce delay from the beginning and lookup to finish and then selects first result for you.
The purpose is to avoid lookup on every keystroke while user is still typing. What the delay should be is subjective of course, but 100ms seems a bit too short to me.
I don't see it that way. If you want to look up something in currently open article you click a link or copy text and paste it into input field. You can also open result links from the list or article list in a new tab if you want to keep them around. Leaving content behind when you clear input feels like app forgot to clean up after itself. |
That's a valid concern. I admit I hadn't considered the possibility to
That's the purpose. You type something and you press enter because you want to open the first result instead of being forced to grab the mouse. You make a very good point that it'd be better if Enter triggered an immediate lookup, but that doesn't change the fact that the lookup + DOM change take time and you don't want to perform any follow-up actions until that's been done. :-) I also realized that there should be a
Hence why I said 100ms rather than
I completely agree about the search results (I forgot to clear them on Escape), but I think emptying the open article is a bit as if my browser killed this very page I'm typing this in just because I decided to alter something in the addressbar. It shouldn't do that until I press Enter or click something in the dropdown. Anyway, I'll change that back if you don't like it, but I really don't think the article you're viewing should be closed except through an explicit user action. For example by pressing Escape on the article, which would then empty out everything and focus the search bar. I pushed a new commit that I think addresses the functionality concerns, but I certainly understand if you're not quite happy about some of the code repetition yet. ;-) |
Hm, I thought of another thing that would improve my experience. Press right arrow while a result is selected → focus article (as opposed to Enter which just loads it) Pushed a demo implementation. |
This doesn't work well with horizontal scrolling, which shows up some in articles with long math formulas or wide tables: Horizontal scroll doesn't happen in word list, but loosing focus on
word input is not exactly browser address bar
I don't like it
Clearing word input is explicit user action |
src/script.js
Outdated
.attr('target', 'content') | ||
// make sure last clicked element is remembered | ||
.on('click', function() { | ||
$($lookupResult).data('selected', this); |
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.
Fixed, good catch.
That's just an example that was close at hand. None of my desktop dictionary or dictionary-type applications clear the article just because you clear the search input. However, several of them replace what you're looking at by automatically opening the top result of what you're typing, which I think is the right approach. As in, either you leave the previous result, or you replace it with the current result. Blank in that scenario only (potentially) applies in case of blank input. To some software blank means opening the letter A, which does have a real paper dictionary-like charm to it. :-P |
src/script.js
Outdated
@@ -86,6 +88,24 @@ $( | |||
$styleSwitcher.setStyle(styleTitle, $content.contents()[0]); | |||
}); | |||
|
|||
var getURLParameter = function(param) |
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.
url query parameters are for server, application state artifacts have no business being exposed like this
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.
Do you mean you'd like to (ab)use the hash instead or that you are against the very concept? Because I think passing a search query directly is must-have functionality (and besides it's conceptually a server parameter hijacked by JS ;-P) and I have some application-state related suggestions that I think would seriously improve usability. Much more so than this silly clear or not clear stuff, although I'd love to sneak that setting in there as well. :-)
* Enter immediately loads the first result * Down arrow immediately looks up results and focuses the first entry of the result list * Escape clears input * Up and down arrows focus links in the result list * Right arrow loads the currently focused result and focuses on article * Escape clears and focuses input * Enter focuses input (without clearing) * Left arrow focuses the current article's entry in the result list if left scrolling is no longer an option * Escape clears and focuses input
Anyway, I stripped out the stuff that's unrelated to the title of this PR and rebased it. |
This change is