aboutsummaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
authorrr-2016-07-05 23:53:49 +0200
committerrr-2016-07-05 23:59:10 +0200
commit7e62751e4e04dfb895e812ecc46a8dfb9c9beb99 (patch)
treeb04b12f9334b30d53147bc8fb1baf5225aa2c54f /client
parent0d9c2b7cc88a6ec79d37ed21ddef6464860cdb84 (diff)
client/tags: fix hovering over autocomplete in FF
Hovering over an autocomplete box always selected the last element rather than the element under the cursor. This is because resultIndex was bound by reference. This looks like a bug in FF implementation of "for (let [x, y] of ...)" -rather than binding "x" and "y" to the scope of the loop, it's equivalent to "for (var [x, y] of ...)", which causes nasty anomalies for functions created inside the loop body.
Diffstat (limited to 'client')
-rw-r--r--client/js/controls/auto_complete_control.js5
1 files changed, 3 insertions, 2 deletions
diff --git a/client/js/controls/auto_complete_control.js b/client/js/controls/auto_complete_control.js
index 4a0da00..2ee735c 100644
--- a/client/js/controls/auto_complete_control.js
+++ b/client/js/controls/auto_complete_control.js
@@ -211,6 +211,7 @@ class AutoCompleteControl {
this._suggestionList.removeChild(this._suggestionList.firstChild);
}
for (let [resultIndex, resultItem] of this._results.entries()) {
+ let resultIndexWorkaround = resultIndex;
const listItem = document.createElement('li');
const link = document.createElement('a');
link.href = '#';
@@ -220,14 +221,14 @@ class AutoCompleteControl {
'mouseenter',
e => {
e.preventDefault();
- this._activeResult = resultIndex;
+ this._activeResult = resultIndexWorkaround;
this._refreshActiveResult();
});
link.addEventListener(
'mousedown',
e => {
e.preventDefault();
- this._activeResult = resultIndex;
+ this._activeResult = resultIndexWorkaround;
this._options.confirm(this._getActiveSuggestion());
this.hide();
});

© 2015 - 2026 Jakob L. Kreuze