Sfoglia il codice sorgente

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 11 mesi fa
parent
commit
b7db565148
1 ha cambiato i file con 8 aggiunte e 0 eliminazioni
  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;