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
v-for="(shortcut, shortcutIndex) in theOutput"
:key="`shortcut-${shortcutIndex}`"
:ref="`item-${shortcutIndex}`"
:shortcut="shortcut"
@action="$emit('action', shortcut.action)"
/>
@@ -62,6 +63,7 @@ export default {
outputHash: "",
theOutput: [],
cache: {},
currentItem: -1,
}
},
computed: {
@@ -119,6 +121,12 @@ export default {
immediate: true,
},
},
mounted() {
document.addEventListener("keydown", this.nextItem)
},
destroyed() {
document.removeEventListener("keydown", this.nextItem)
},
methods: {
async output(search) {
const that = this
@@ -196,6 +204,24 @@ export default {
const hex = val.toString(16).toUpperCase()
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>

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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