UX: allows to navigate widget dropdown with tab and enter (#10356)

UX: allows to navigate widget dropdown with tab and enter (#10356)

diff --git a/app/assets/javascripts/discourse/app/widgets/widget-dropdown.js b/app/assets/javascripts/discourse/app/widgets/widget-dropdown.js
index 0f0548f..3633560 100644
--- a/app/assets/javascripts/discourse/app/widgets/widget-dropdown.js
+++ b/app/assets/javascripts/discourse/app/widgets/widget-dropdown.js
@@ -114,7 +114,10 @@ export const WidgetDropdownItemClass = {
   },
 
   buildAttributes(attrs) {
-    return { "data-id": attrs.item.id };
+    return {
+      "data-id": attrs.item.id,
+      tabindex: attrs.item === "separator" ? -1 : 0
+    };
   },
 
   buildClasses(attrs) {
@@ -124,6 +127,13 @@ export const WidgetDropdownItemClass = {
     ].join(" ");
   },
 
+  keyDown(event) {
+    if (event.key === "Enter") {
+      event.preventDefault();
+      this.sendWidgetAction("_onChange", this.attrs.item);
+    }
+  },
+
   click(event) {
     event.preventDefault();
 

GitHub sha: eb61916e

1 Like

This commit appears in #10356 which was merged by jjaffeux.