Skip to content

A platform for community discussion. Free, open, simple.

UX: adds arrow navigation support to mini-tag-chooser (#8857)

Joffrey JAFFEUX7fd5a8db723a
diff --git a/app/assets/javascripts/select-kit/components/mini-tag-chooser.js.es6 b/app/assets/javascripts/select-kit/components/mini-tag-chooser.js.es6
index 6284181bbeb..90ef12c7058 100644
--- a/app/assets/javascripts/select-kit/components/mini-tag-chooser.js.es6
+++ b/app/assets/javascripts/select-kit/components/mini-tag-chooser.js.es6
@@ -165,8 +165,30 @@ export default ComboBox.extend(TagsMixin, {
},
_onKeydown(event) {
+ const value = makeArray(this.value);
+
if (event.keyCode === 8) {
this._onBackspace(this.value, this.highlightedTag);
+ } else if (event.keyCode === 37) {
+ if (this.highlightedTag) {
+ const index = value.indexOf(this.highlightedTag);
+ const highlightedTag = value[index - 1]
+ ? value[index - 1]
+ : value.lastObject;
+ this.set("highlightedTag", highlightedTag);
+ } else {
+ this.set("highlightedTag", value.lastObject);
+ }
+ } else if (event.keyCode === 39) {
+ if (this.highlightedTag) {
+ const index = value.indexOf(this.highlightedTag);
+ const highlightedTag = value[index + 1]
+ ? value[index + 1]
+ : value.firstObject;
+ this.set("highlightedTag", highlightedTag);
+ } else {
+ this.set("highlightedTag", value.firstObject);
+ }
} else {
this.set("highlightedTag", null);
}