feat: disable autocomplete on inputs + keyboard navigation focus

This commit is contained in:
liyasthomas
2021-08-29 16:44:18 +05:30
parent ebd8f43219
commit 04f9428267
33 changed files with 66 additions and 2 deletions

View File

@@ -3,6 +3,7 @@
<AppSearchEntry <AppSearchEntry
v-for="(shortcut, shortcutIndex) in theOutput" v-for="(shortcut, shortcutIndex) in theOutput"
:key="`shortcut-${shortcutIndex}`" :key="`shortcut-${shortcutIndex}`"
:ref="`item-${shortcutIndex}`"
:shortcut="shortcut" :shortcut="shortcut"
@action="$emit('action', shortcut.action)" @action="$emit('action', shortcut.action)"
/> />
@@ -62,6 +63,7 @@ export default {
outputHash: "", outputHash: "",
theOutput: [], theOutput: [],
cache: {}, cache: {},
currentItem: -1,
} }
}, },
computed: { computed: {
@@ -119,6 +121,12 @@ export default {
immediate: true, immediate: true,
}, },
}, },
mounted() {
document.addEventListener("keydown", this.nextItem)
},
destroyed() {
document.removeEventListener("keydown", this.nextItem)
},
methods: { methods: {
async output(search) { async output(search) {
const that = this const that = this
@@ -196,6 +204,24 @@ export default {
const hex = val.toString(16).toUpperCase() const hex = val.toString(16).toUpperCase()
return `00000000${hex}`.slice(-8) return `00000000${hex}`.slice(-8)
}, },
nextItem(e) {
if (e.keyCode === 38 && this.currentItem > 0) {
e.preventDefault()
this.currentItem--
this.$nextTick().then(() => {
this.$refs[`item-${this.currentItem}`][0].$el.focus()
})
} else if (
e.keyCode === 40 &&
this.currentItem < this.theOutput.length - 1
) {
e.preventDefault()
this.currentItem++
this.$nextTick().then(() => {
this.$refs[`item-${this.currentItem}`][0].$el.focus()
})
}
},
}, },
} }
</script> </script>

View File

@@ -6,6 +6,7 @@
v-model="search" v-model="search"
v-focus v-focus
type="text" type="text"
autocomplete="off"
name="command" name="command"
:placeholder="$t('app.type_a_command_search')" :placeholder="$t('app.type_a_command_search')"
class=" class="

View File

@@ -23,7 +23,7 @@
<div class="flex flex-col my-4 mx-6"> <div class="flex flex-col my-4 mx-6">
<input <input
v-model="filterText" v-model="filterText"
type="search" type="search" autocomplete="off"
class=" class="
bg-primaryLight bg-primaryLight
border border-dividerLight border border-dividerLight

View File

@@ -9,6 +9,7 @@
class="input floating-input" class="input floating-input"
placeholder=" " placeholder=" "
type="text" type="text"
autocomplete="off"
@keyup.enter="addNewCollection" @keyup.enter="addNewCollection"
/> />
<label for="selectLabelAdd"> <label for="selectLabelAdd">

View File

@@ -13,6 +13,7 @@
class="input floating-input" class="input floating-input"
placeholder=" " placeholder=" "
type="text" type="text"
autocomplete="off"
@keyup.enter="addFolder" @keyup.enter="addFolder"
/> />
<label for="selectLabelAddFolder"> <label for="selectLabelAddFolder">

View File

@@ -16,6 +16,7 @@
<select <select
id="team" id="team"
type="text" type="text"
autocomplete="off"
autofocus autofocus
class=" class="
bg-transparent bg-transparent

View File

@@ -9,6 +9,7 @@
class="input floating-input" class="input floating-input"
placeholder=" " placeholder=" "
type="text" type="text"
autocomplete="off"
@keyup.enter="saveCollection" @keyup.enter="saveCollection"
/> />
<label for="selectLabelEdit"> <label for="selectLabelEdit">

View File

@@ -13,6 +13,7 @@
class="input floating-input" class="input floating-input"
placeholder=" " placeholder=" "
type="text" type="text"
autocomplete="off"
@keyup.enter="editFolder" @keyup.enter="editFolder"
/> />
<label for="selectLabelEditFolder"> <label for="selectLabelEditFolder">

View File

@@ -9,6 +9,7 @@
class="input floating-input" class="input floating-input"
placeholder=" " placeholder=" "
type="text" type="text"
autocomplete="off"
@keyup.enter="saveRequest" @keyup.enter="saveRequest"
/> />
<label for="selectLabelEditReq"> <label for="selectLabelEditReq">

View File

@@ -127,6 +127,7 @@
<div class="select-wrapper"> <div class="select-wrapper">
<select <select
type="text" type="text"
autocomplete="off"
class="select" class="select"
autofocus autofocus
@change=" @change="

View File

@@ -10,6 +10,7 @@
class="input floating-input" class="input floating-input"
placeholder=" " placeholder=" "
type="text" type="text"
autocomplete="off"
@keyup.enter="saveRequestAs" @keyup.enter="saveRequestAs"
/> />
<label for="selectLabelSaveReq"> <label for="selectLabelSaveReq">

View File

@@ -9,6 +9,7 @@
class="input floating-input" class="input floating-input"
placeholder=" " placeholder=" "
type="text" type="text"
autocomplete="off"
@keyup.enter="addNewCollection" @keyup.enter="addNewCollection"
/> />
<label for="selectLabelGqlAdd"> <label for="selectLabelGqlAdd">

View File

@@ -13,6 +13,7 @@
class="input floating-input" class="input floating-input"
placeholder=" " placeholder=" "
type="text" type="text"
autocomplete="off"
@keyup.enter="addFolder" @keyup.enter="addFolder"
/> />
<label for="selectLabelGqlAddFolder"> <label for="selectLabelGqlAddFolder">

View File

@@ -9,6 +9,7 @@
class="input floating-input" class="input floating-input"
placeholder=" " placeholder=" "
type="text" type="text"
autocomplete="off"
@keyup.enter="saveCollection" @keyup.enter="saveCollection"
/> />
<label for="selectLabelGqlEdit"> <label for="selectLabelGqlEdit">

View File

@@ -13,6 +13,7 @@
class="input floating-input" class="input floating-input"
placeholder=" " placeholder=" "
type="text" type="text"
autocomplete="off"
@keyup.enter="editFolder" @keyup.enter="editFolder"
/> />
<label for="selectLabelGqlEditFolder"> <label for="selectLabelGqlEditFolder">

View File

@@ -9,6 +9,7 @@
class="input floating-input" class="input floating-input"
placeholder=" " placeholder=" "
type="text" type="text"
autocomplete="off"
@keyup.enter="saveRequest" @keyup.enter="saveRequest"
/> />
<label for="selectLabelGqlEditReq"> <label for="selectLabelGqlEditReq">

View File

@@ -18,6 +18,7 @@
v-if="showCollActions" v-if="showCollActions"
v-model="filterText" v-model="filterText"
type="search" type="search"
autocomplete="off"
:placeholder="$t('action.search')" :placeholder="$t('action.search')"
class="bg-transparent flex w-full py-2 px-4" class="bg-transparent flex w-full py-2 px-4"
/> />

View File

@@ -20,6 +20,7 @@
<input <input
v-model="filterText" v-model="filterText"
type="search" type="search"
autocomplete="off"
:placeholder="$t('action.search')" :placeholder="$t('action.search')"
class="bg-transparent flex w-full py-2 pr-2 pl-4" class="bg-transparent flex w-full py-2 pr-2 pl-4"
/> />

View File

@@ -9,6 +9,7 @@
class="input floating-input" class="input floating-input"
placeholder=" " placeholder=" "
type="text" type="text"
autocomplete="off"
@keyup.enter="addNewEnvironment" @keyup.enter="addNewEnvironment"
/> />
<label for="selectLabelEnvAdd"> <label for="selectLabelEnvAdd">

View File

@@ -10,6 +10,7 @@
class="input floating-input" class="input floating-input"
placeholder=" " placeholder=" "
type="text" type="text"
autocomplete="off"
:disabled="editingEnvironmentIndex === 'Global'" :disabled="editingEnvironmentIndex === 'Global'"
@keyup.enter="saveEnvironment" @keyup.enter="saveEnvironment"
/> />

View File

@@ -35,7 +35,7 @@
placeholder=" " placeholder=" "
type="email" type="email"
name="email" name="email"
autocomplete="email" autocomplete="off"
required required
spellcheck="false" spellcheck="false"
autofocus autofocus

View File

@@ -6,6 +6,7 @@
v-model="url" v-model="url"
v-focus v-focus
type="url" type="url"
autocomplete="off"
spellcheck="false" spellcheck="false"
class=" class="
bg-primaryLight bg-primaryLight

View File

@@ -7,6 +7,7 @@
<input <input
v-model="graphqlFieldsFilterText" v-model="graphqlFieldsFilterText"
type="search" type="search"
autocomplete="off"
:placeholder="$t('action.search')" :placeholder="$t('action.search')"
class="bg-transparent flex w-full p-4 py-2" class="bg-transparent flex w-full p-4 py-2"
/> />

View File

@@ -13,6 +13,7 @@
<input <input
v-model="filterText" v-model="filterText"
type="search" type="search"
autocomplete="off"
class="bg-transparent flex w-full p-4 py-2" class="bg-transparent flex w-full p-4 py-2"
:placeholder="$t('action.search')" :placeholder="$t('action.search')"
/> />

View File

@@ -84,6 +84,7 @@
" "
name="url" name="url"
type="text" type="text"
autocomplete="off"
spellcheck="false" spellcheck="false"
:placeholder="$t('request.url')" :placeholder="$t('request.url')"
autofocus autofocus
@@ -166,6 +167,7 @@
:placeholder="$t('request.name')" :placeholder="$t('request.name')"
name="request-name" name="request-name"
type="text" type="text"
autocomplete="off"
class="mb-2 input" class="mb-2 input"
@keyup.enter="saveOptions.tippy().hide()" @keyup.enter="saveOptions.tippy().hide()"
/> />

View File

@@ -11,6 +11,7 @@
v-model="url" v-model="url"
v-focus v-focus
type="url" type="url"
autocomplete="off"
spellcheck="false" spellcheck="false"
class=" class="
bg-primaryLight bg-primaryLight
@@ -69,6 +70,7 @@
class="input" class="input"
:placeholder="$t('mqtt.topic_name')" :placeholder="$t('mqtt.topic_name')"
type="text" type="text"
autocomplete="off"
spellcheck="false" spellcheck="false"
/> />
</div> </div>
@@ -83,6 +85,7 @@
v-model="msg" v-model="msg"
class="input" class="input"
type="text" type="text"
autocomplete="off"
:placeholder="$t('mqtt.message')" :placeholder="$t('mqtt.message')"
spellcheck="false" spellcheck="false"
/> />
@@ -112,6 +115,7 @@
id="sub_topic" id="sub_topic"
v-model="sub_topic" v-model="sub_topic"
type="text" type="text"
autocomplete="off"
:placeholder="$t('mqtt.topic_name')" :placeholder="$t('mqtt.topic_name')"
spellcheck="false" spellcheck="false"
class="input" class="input"

View File

@@ -12,6 +12,7 @@
v-model="url" v-model="url"
v-focus v-focus
type="url" type="url"
autocomplete="off"
spellcheck="false" spellcheck="false"
:class="{ error: !urlValid }" :class="{ error: !urlValid }"
class=" class="
@@ -94,6 +95,7 @@
name="event_name" name="event_name"
:placeholder="$t('socketio.event_name')" :placeholder="$t('socketio.event_name')"
type="text" type="text"
autocomplete="off"
:disabled="!connectionState" :disabled="!connectionState"
/> />
</div> </div>
@@ -123,6 +125,7 @@
name="message" name="message"
:placeholder="$t('count.message', { count: index + 1 })" :placeholder="$t('count.message', { count: index + 1 })"
type="text" type="text"
autocomplete="off"
:disabled="!connectionState" :disabled="!connectionState"
@keyup.enter="connectionState ? sendMessage() : null" @keyup.enter="connectionState ? sendMessage() : null"
/> />

View File

@@ -9,6 +9,7 @@
v-model="server" v-model="server"
v-focus v-focus
type="url" type="url"
autocomplete="off"
:class="{ error: !serverValid }" :class="{ error: !serverValid }"
class=" class="
bg-primaryLight bg-primaryLight

View File

@@ -23,6 +23,7 @@
focus-visible:border-dividerDark focus-visible:border-dividerDark
" "
type="url" type="url"
autocomplete="off"
spellcheck="false" spellcheck="false"
:class="{ error: !urlValid }" :class="{ error: !urlValid }"
:placeholder="$t('websocket.url')" :placeholder="$t('websocket.url')"
@@ -89,6 +90,7 @@
:placeholder="$t('count.protocol', { count: index + 1 })" :placeholder="$t('count.protocol', { count: index + 1 })"
name="message" name="message"
type="text" type="text"
autocomplete="off"
/> />
<span> <span>
<ButtonSecondary <ButtonSecondary
@@ -174,6 +176,7 @@
v-model="communication.input" v-model="communication.input"
name="message" name="message"
type="text" type="text"
autocomplete="off"
:disabled="!connectionState" :disabled="!connectionState"
:placeholder="$t('websocket.message')" :placeholder="$t('websocket.message')"
class="input" class="input"

View File

@@ -4,6 +4,7 @@
ref="acInput" ref="acInput"
v-model="text" v-model="text"
type="text" type="text"
autocomplete="off"
:placeholder="placeholder" :placeholder="placeholder"
:spellcheck="spellcheck" :spellcheck="spellcheck"
:autocapitalize="autocapitalize" :autocapitalize="autocapitalize"

View File

@@ -9,6 +9,7 @@
class="input floating-input" class="input floating-input"
placeholder=" " placeholder=" "
type="text" type="text"
autocomplete="off"
@keyup.enter="addNewTeam" @keyup.enter="addNewTeam"
/> />
<label for="selectLabelTeamAdd"> <label for="selectLabelTeamAdd">

View File

@@ -10,6 +10,7 @@
class="input floating-input" class="input floating-input"
placeholder=" " placeholder=" "
type="text" type="text"
autocomplete="off"
@keyup.enter="saveTeam" @keyup.enter="saveTeam"
/> />
<label for="selectLabelTeamEdit"> <label for="selectLabelTeamEdit">

View File

@@ -305,6 +305,7 @@
class="input floating-input" class="input floating-input"
placeholder=" " placeholder=" "
type="url" type="url"
autocomplete="off"
:disabled="!PROXY_ENABLED" :disabled="!PROXY_ENABLED"
/> />
<label for="url"> <label for="url">