Skip to content

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

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

Joffrey JAFFEUXeb61916e23ca
diff --git a/app/assets/javascripts/discourse/app/widgets/widget-dropdown.js b/app/assets/javascripts/discourse/app/widgets/widget-dropdown.js
index 0f0548fccc9..363356048a0 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();