4 ms·
One suggestion is to complete on TAB with the first or the only tag in the completion list, so that the user does not have to reach for the mouse. Ideally comp
by mynegation 10y ago
One suggestion is to complete on TAB with the first or the only tag in the completion list, so that the user does not have to reach for the mouse. Ideally completion list should be sorted by usage frequency too, but that is next level. For an example of how it's done properly, I can refer to the pinboard.in bookmarking dialog (@idlewords, you rule)
- Kequc 10y agoWhat I like is that all the code is laid bare. You could add a line or two into the `_onKeyup` method which does this. These tags are sorted by popularity. if (this.parts.suggestions && (e.which || e.charCode || e.keyCode) == 9) { let foo = this.parts.suggestions.children.item(0); if (foo) foo.click(); }
- justinlardinois 10y agoI'm a little confused; what's going on in the part of the main if condition after the &&? It looks like the author intended to check if any of e.which, e.charCode, or e.keyCode equal 9, but obviously that's not what would happen.
- sago 10y ago'obviously'? The code looks fine to me, c.f.: $ node > undefined || undefined || 4 4 > undefined || 9 || 4 9 The || operator evaluates to the first of its two operands if it is truthy, or its second operand otherwise > undefined || false false > false || undefined undefined So: > e = {keyCode:9} > e.which || e.charCode || e.keyCode 9