feat: auto focus directive, auto focus primary action by default

This commit is contained in:
liyasthomas
2021-08-08 22:44:05 +05:30
parent a71f70644f
commit cbf99d2daf
28 changed files with 38 additions and 7 deletions

View File

@@ -23,6 +23,7 @@
<!-- <div class="search-wrapper">
<input
v-model="filterText"
v-focus
type="search"
class="bg-primaryLight border-b border-dividerLight flex font-semibold font-mono w-full py-2 pr-2 pl-8 truncate focus:outline-none"
:placeholder="$t('search')"

View File

@@ -5,6 +5,7 @@
<input
id="selectLabelAdd"
v-model="name"
v-focus
class="input floating-input"
placeholder=" "
type="text"

View File

@@ -9,6 +9,7 @@
<input
id="selectLabelAddFolder"
v-model="name"
v-focus
class="input floating-input"
placeholder=" "
type="text"

View File

@@ -5,6 +5,7 @@
<input
id="selectLabelEdit"
v-model="name"
v-focus
class="input floating-input"
placeholder=" "
type="text"

View File

@@ -9,6 +9,7 @@
<input
id="selectLabelEditFolder"
v-model="name"
v-focus
class="input floating-input"
placeholder=" "
type="text"

View File

@@ -5,6 +5,7 @@
<input
id="selectLabelEditReq"
v-model="requestUpdateData.name"
v-focus
class="input floating-input"
placeholder=" "
type="text"

View File

@@ -6,6 +6,7 @@
<input
id="selectLabelSaveReq"
v-model="requestName"
v-focus
class="input floating-input"
placeholder=" "
type="text"

View File

@@ -5,6 +5,7 @@
<input
id="selectLabelGqlAdd"
v-model="name"
v-focus
class="input floating-input"
placeholder=" "
type="text"

View File

@@ -9,6 +9,7 @@
<input
id="selectLabelGqlAddFolder"
v-model="name"
v-focus
class="input floating-input"
placeholder=" "
type="text"

View File

@@ -5,6 +5,7 @@
<input
id="selectLabelGqlEdit"
v-model="name"
v-focus
class="input floating-input"
placeholder=" "
type="text"

View File

@@ -9,6 +9,7 @@
<input
id="selectLabelGqlEditFolder"
v-model="name"
v-focus
class="input floating-input"
placeholder=" "
type="text"

View File

@@ -5,6 +5,7 @@
<input
id="selectLabelGqlEditReq"
v-model="requestUpdateData.name"
v-focus
class="input floating-input"
placeholder=" "
type="text"

View File

@@ -5,6 +5,7 @@
<input
id="selectLabelEnvAdd"
v-model="name"
v-focus
class="input floating-input"
placeholder=" "
type="text"

View File

@@ -6,6 +6,7 @@
<input
id="selectLabelEnvEdit"
v-model="name"
v-focus
class="input floating-input"
placeholder=" "
type="text"

View File

@@ -30,6 +30,7 @@
<input
id="email"
v-model="form.email"
v-focus
class="input floating-input"
placeholder=" "
type="email"

View File

@@ -66,6 +66,7 @@
v-else
id="url"
v-model="newEndpoint"
v-focus
class="
bg-primaryLight
border border-divider

View File

@@ -9,6 +9,7 @@
<input
id="mqtt-url"
v-model="url"
v-focus
type="url"
spellcheck="false"
class="

View File

@@ -9,6 +9,7 @@
<input
id="socketio-url"
v-model="url"
v-focus
type="url"
spellcheck="false"
:class="{ error: !urlValid }"

View File

@@ -6,6 +6,7 @@
<input
id="server"
v-model="server"
v-focus
type="url"
:class="{ error: !serverValid }"
class="

View File

@@ -9,6 +9,7 @@
<input
id="websocket-url"
v-model="url"
v-focus
class="
bg-primaryLight
border border-divider

View File

@@ -9,7 +9,7 @@
</template>
<template #footer>
<span>
<ButtonPrimary :label="yes" @click.native="resolve" />
<ButtonPrimary v-focus :label="yes" @click.native="resolve" />
<ButtonSecondary :label="no" @click.native="hideModal" />
</span>
</template>

View File

@@ -4,11 +4,11 @@
-->
<template>
<div class="url-field-container">
<div class="env-input-container">
<div
ref="editor"
:placeholder="placeholder"
class="url-field"
class="env-input"
:class="styles"
contenteditable="true"
@keydown.enter.prevent="$emit('enter', $event)"
@@ -477,12 +477,12 @@ export default defineComponent({
}
}
.url-field-container {
.env-input-container {
@apply inline-grid;
@apply w-full;
}
.url-field {
.env-input {
@apply flex;
@apply items-center;
@apply justify-items-start;
@@ -492,7 +492,7 @@ export default defineComponent({
@apply resize-none;
}
.url-field::-webkit-scrollbar {
.env-input::-webkit-scrollbar {
@apply hidden;
}
</style>

View File

@@ -12,7 +12,7 @@ const factory = (props) =>
* inputting values.
*/
describe("url-field", () => {
describe("env-input", () => {
test("mounts properly", () => {
const wrapper = factory({
value: "test",

View File

@@ -5,6 +5,7 @@
<input
id="selectLabelTeamAdd"
v-model="name"
v-focus
class="input floating-input"
placeholder=" "
type="text"

View File

@@ -5,6 +5,7 @@
<input
id="selectLabelTeamEdit"
v-model="name"
v-focus
class="input floating-input"
placeholder=" "
type="text"

View File

@@ -94,6 +94,7 @@ export default {
// Plugins to run before rendering page (https://go.nuxtjs.dev/config-plugins)
plugins: [
"~/plugins/v-tippy",
"~/plugins/v-focus",
"~/plugins/vuex-persist",
"~/plugins/vue-rx",
"~/plugins/vue-apollo",

View File

@@ -9,6 +9,7 @@
<input
id="url"
v-model="url"
v-focus
type="url"
spellcheck="false"
class="

7
plugins/v-focus.js Normal file
View File

@@ -0,0 +1,7 @@
import Vue from "vue"
Vue.directive("focus", {
inserted: (el) => {
Vue.nextTick(() => el.focus())
},
})