Procházet zdrojové kódy

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 před 11 měsíci
rodič
revize
b7db565148
1 změnil soubory, kde provedl 8 přidání a 0 odebrání
  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;