Skip to content

Commit

Permalink
Fixes webcompat#1489 - Gets everything working in different browsers …
Browse files Browse the repository at this point in the history
…and a little bit of code clean up.
  • Loading branch information
brizental committed May 4, 2017
1 parent a7b1dfe commit 0846425
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions webcompat/static/js/lib/labels.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ issues.LabelEditorView = Backbone.View.extend({
"keyup": "closeEditor",
"keyup .wc-LabelEditor-search": "filterLabels",
"keyup .wc-LabelEditor-list-item": "checkUncheckLabels",
"keydown .wc-LabelEditor-list-item:visible:first input": "removeFocus",
"keydown .wc-LabelEditor-list-item": "removeFocus",
"keydown .wc-LabelEditor-list-item:visible:last": "backToTop"
},
keyboardEvents: {
Expand Down Expand Up @@ -199,7 +199,7 @@ issues.LabelEditorView = Backbone.View.extend({
if (e.keyCode === 13) {
$(".wc-LabelEditor-list-item:visible:first").focus();
// if you call the focus() function in a label element,'
// the focues automatically goes ato the input.
// the focus automatically goes to the input.
// that's why we need to add the focused class.
$(".wc-LabelEditor-list-item:visible:first").addClass("focused");
}
Expand All @@ -226,13 +226,12 @@ issues.LabelEditorView = Backbone.View.extend({
checkUncheckLabels: _.debounce(function(e) {
if (e.keyCode === 13) {
$(e.target).click();
$(e.target).addClass("focused");
}
}, 100),
removeFocus: _.debounce(function(e) {
console.log(e.keyCode);
if (e.keyCode === 9) {
console.log($(".wc-LabelEditor-list-item:visible:first").hasClass("focused"));
$(".wc-LabelEditor-list-item:visible:first").removeClass("focused");
$(e.target).closest("label").removeClass("focused");
}
}, 100),
backToTop: _.debounce(function(e) {
Expand Down

0 comments on commit 0846425

Please sign in to comment.