Explorar o código

Improved accessibility:

* Autocomplete fields: shift+tab should always give focus to previous
  focusable element, and tab should give the focus to next focusable
  element if the input is empty.
John Livingston hai 1 ano
pai
achega
4b7f7f1be6
Modificáronse 1 ficheiros con 8 adicións e 0 borrados
  1. 8 0
      src/shared/autocomplete/autocomplete.js

+ 8 - 0
src/shared/autocomplete/autocomplete.js

@@ -253,6 +253,14 @@ export class AutoComplete extends EventEmitter(Object) {
 
         if (this.ac_triggers.includes(ev.key)) {
             if (ev.key === "Tab") {
+                if (ev.shiftKey) {
+                    // TAB + shift should give the focus to previous focusable element.
+                    return
+                }
+                // If the input is empty (and min_chars > 0), TAB should give focus to next focusable element.
+                if (this.min_chars > 0 && this.input.value === '') {
+                    return
+                }
                 ev.preventDefault();
             }
             this.auto_completing = true;