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

This commit is contained in:
Joffrey JAFFEUX 2020-08-03 10:37:30 +02:00 committed by GitHub
parent 12913a46e4
commit eb61916e23
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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();