feat: auto focus directive, auto focus primary action by default
This commit is contained in:
@@ -23,6 +23,7 @@
|
|||||||
<!-- <div class="search-wrapper">
|
<!-- <div class="search-wrapper">
|
||||||
<input
|
<input
|
||||||
v-model="filterText"
|
v-model="filterText"
|
||||||
|
v-focus
|
||||||
type="search"
|
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"
|
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')"
|
:placeholder="$t('search')"
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
<input
|
<input
|
||||||
id="selectLabelAdd"
|
id="selectLabelAdd"
|
||||||
v-model="name"
|
v-model="name"
|
||||||
|
v-focus
|
||||||
class="input floating-input"
|
class="input floating-input"
|
||||||
placeholder=" "
|
placeholder=" "
|
||||||
type="text"
|
type="text"
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
<input
|
<input
|
||||||
id="selectLabelAddFolder"
|
id="selectLabelAddFolder"
|
||||||
v-model="name"
|
v-model="name"
|
||||||
|
v-focus
|
||||||
class="input floating-input"
|
class="input floating-input"
|
||||||
placeholder=" "
|
placeholder=" "
|
||||||
type="text"
|
type="text"
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
<input
|
<input
|
||||||
id="selectLabelEdit"
|
id="selectLabelEdit"
|
||||||
v-model="name"
|
v-model="name"
|
||||||
|
v-focus
|
||||||
class="input floating-input"
|
class="input floating-input"
|
||||||
placeholder=" "
|
placeholder=" "
|
||||||
type="text"
|
type="text"
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
<input
|
<input
|
||||||
id="selectLabelEditFolder"
|
id="selectLabelEditFolder"
|
||||||
v-model="name"
|
v-model="name"
|
||||||
|
v-focus
|
||||||
class="input floating-input"
|
class="input floating-input"
|
||||||
placeholder=" "
|
placeholder=" "
|
||||||
type="text"
|
type="text"
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
<input
|
<input
|
||||||
id="selectLabelEditReq"
|
id="selectLabelEditReq"
|
||||||
v-model="requestUpdateData.name"
|
v-model="requestUpdateData.name"
|
||||||
|
v-focus
|
||||||
class="input floating-input"
|
class="input floating-input"
|
||||||
placeholder=" "
|
placeholder=" "
|
||||||
type="text"
|
type="text"
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
<input
|
<input
|
||||||
id="selectLabelSaveReq"
|
id="selectLabelSaveReq"
|
||||||
v-model="requestName"
|
v-model="requestName"
|
||||||
|
v-focus
|
||||||
class="input floating-input"
|
class="input floating-input"
|
||||||
placeholder=" "
|
placeholder=" "
|
||||||
type="text"
|
type="text"
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
<input
|
<input
|
||||||
id="selectLabelGqlAdd"
|
id="selectLabelGqlAdd"
|
||||||
v-model="name"
|
v-model="name"
|
||||||
|
v-focus
|
||||||
class="input floating-input"
|
class="input floating-input"
|
||||||
placeholder=" "
|
placeholder=" "
|
||||||
type="text"
|
type="text"
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
<input
|
<input
|
||||||
id="selectLabelGqlAddFolder"
|
id="selectLabelGqlAddFolder"
|
||||||
v-model="name"
|
v-model="name"
|
||||||
|
v-focus
|
||||||
class="input floating-input"
|
class="input floating-input"
|
||||||
placeholder=" "
|
placeholder=" "
|
||||||
type="text"
|
type="text"
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
<input
|
<input
|
||||||
id="selectLabelGqlEdit"
|
id="selectLabelGqlEdit"
|
||||||
v-model="name"
|
v-model="name"
|
||||||
|
v-focus
|
||||||
class="input floating-input"
|
class="input floating-input"
|
||||||
placeholder=" "
|
placeholder=" "
|
||||||
type="text"
|
type="text"
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
<input
|
<input
|
||||||
id="selectLabelGqlEditFolder"
|
id="selectLabelGqlEditFolder"
|
||||||
v-model="name"
|
v-model="name"
|
||||||
|
v-focus
|
||||||
class="input floating-input"
|
class="input floating-input"
|
||||||
placeholder=" "
|
placeholder=" "
|
||||||
type="text"
|
type="text"
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
<input
|
<input
|
||||||
id="selectLabelGqlEditReq"
|
id="selectLabelGqlEditReq"
|
||||||
v-model="requestUpdateData.name"
|
v-model="requestUpdateData.name"
|
||||||
|
v-focus
|
||||||
class="input floating-input"
|
class="input floating-input"
|
||||||
placeholder=" "
|
placeholder=" "
|
||||||
type="text"
|
type="text"
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
<input
|
<input
|
||||||
id="selectLabelEnvAdd"
|
id="selectLabelEnvAdd"
|
||||||
v-model="name"
|
v-model="name"
|
||||||
|
v-focus
|
||||||
class="input floating-input"
|
class="input floating-input"
|
||||||
placeholder=" "
|
placeholder=" "
|
||||||
type="text"
|
type="text"
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
<input
|
<input
|
||||||
id="selectLabelEnvEdit"
|
id="selectLabelEnvEdit"
|
||||||
v-model="name"
|
v-model="name"
|
||||||
|
v-focus
|
||||||
class="input floating-input"
|
class="input floating-input"
|
||||||
placeholder=" "
|
placeholder=" "
|
||||||
type="text"
|
type="text"
|
||||||
|
|||||||
@@ -30,6 +30,7 @@
|
|||||||
<input
|
<input
|
||||||
id="email"
|
id="email"
|
||||||
v-model="form.email"
|
v-model="form.email"
|
||||||
|
v-focus
|
||||||
class="input floating-input"
|
class="input floating-input"
|
||||||
placeholder=" "
|
placeholder=" "
|
||||||
type="email"
|
type="email"
|
||||||
|
|||||||
@@ -66,6 +66,7 @@
|
|||||||
v-else
|
v-else
|
||||||
id="url"
|
id="url"
|
||||||
v-model="newEndpoint"
|
v-model="newEndpoint"
|
||||||
|
v-focus
|
||||||
class="
|
class="
|
||||||
bg-primaryLight
|
bg-primaryLight
|
||||||
border border-divider
|
border border-divider
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
<input
|
<input
|
||||||
id="mqtt-url"
|
id="mqtt-url"
|
||||||
v-model="url"
|
v-model="url"
|
||||||
|
v-focus
|
||||||
type="url"
|
type="url"
|
||||||
spellcheck="false"
|
spellcheck="false"
|
||||||
class="
|
class="
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
<input
|
<input
|
||||||
id="socketio-url"
|
id="socketio-url"
|
||||||
v-model="url"
|
v-model="url"
|
||||||
|
v-focus
|
||||||
type="url"
|
type="url"
|
||||||
spellcheck="false"
|
spellcheck="false"
|
||||||
:class="{ error: !urlValid }"
|
:class="{ error: !urlValid }"
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
<input
|
<input
|
||||||
id="server"
|
id="server"
|
||||||
v-model="server"
|
v-model="server"
|
||||||
|
v-focus
|
||||||
type="url"
|
type="url"
|
||||||
:class="{ error: !serverValid }"
|
:class="{ error: !serverValid }"
|
||||||
class="
|
class="
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
<input
|
<input
|
||||||
id="websocket-url"
|
id="websocket-url"
|
||||||
v-model="url"
|
v-model="url"
|
||||||
|
v-focus
|
||||||
class="
|
class="
|
||||||
bg-primaryLight
|
bg-primaryLight
|
||||||
border border-divider
|
border border-divider
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
</template>
|
</template>
|
||||||
<template #footer>
|
<template #footer>
|
||||||
<span>
|
<span>
|
||||||
<ButtonPrimary :label="yes" @click.native="resolve" />
|
<ButtonPrimary v-focus :label="yes" @click.native="resolve" />
|
||||||
<ButtonSecondary :label="no" @click.native="hideModal" />
|
<ButtonSecondary :label="no" @click.native="hideModal" />
|
||||||
</span>
|
</span>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -4,11 +4,11 @@
|
|||||||
-->
|
-->
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="url-field-container">
|
<div class="env-input-container">
|
||||||
<div
|
<div
|
||||||
ref="editor"
|
ref="editor"
|
||||||
:placeholder="placeholder"
|
:placeholder="placeholder"
|
||||||
class="url-field"
|
class="env-input"
|
||||||
:class="styles"
|
:class="styles"
|
||||||
contenteditable="true"
|
contenteditable="true"
|
||||||
@keydown.enter.prevent="$emit('enter', $event)"
|
@keydown.enter.prevent="$emit('enter', $event)"
|
||||||
@@ -477,12 +477,12 @@ export default defineComponent({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.url-field-container {
|
.env-input-container {
|
||||||
@apply inline-grid;
|
@apply inline-grid;
|
||||||
@apply w-full;
|
@apply w-full;
|
||||||
}
|
}
|
||||||
|
|
||||||
.url-field {
|
.env-input {
|
||||||
@apply flex;
|
@apply flex;
|
||||||
@apply items-center;
|
@apply items-center;
|
||||||
@apply justify-items-start;
|
@apply justify-items-start;
|
||||||
@@ -492,7 +492,7 @@ export default defineComponent({
|
|||||||
@apply resize-none;
|
@apply resize-none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.url-field::-webkit-scrollbar {
|
.env-input::-webkit-scrollbar {
|
||||||
@apply hidden;
|
@apply hidden;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ const factory = (props) =>
|
|||||||
* inputting values.
|
* inputting values.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
describe("url-field", () => {
|
describe("env-input", () => {
|
||||||
test("mounts properly", () => {
|
test("mounts properly", () => {
|
||||||
const wrapper = factory({
|
const wrapper = factory({
|
||||||
value: "test",
|
value: "test",
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
<input
|
<input
|
||||||
id="selectLabelTeamAdd"
|
id="selectLabelTeamAdd"
|
||||||
v-model="name"
|
v-model="name"
|
||||||
|
v-focus
|
||||||
class="input floating-input"
|
class="input floating-input"
|
||||||
placeholder=" "
|
placeholder=" "
|
||||||
type="text"
|
type="text"
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
<input
|
<input
|
||||||
id="selectLabelTeamEdit"
|
id="selectLabelTeamEdit"
|
||||||
v-model="name"
|
v-model="name"
|
||||||
|
v-focus
|
||||||
class="input floating-input"
|
class="input floating-input"
|
||||||
placeholder=" "
|
placeholder=" "
|
||||||
type="text"
|
type="text"
|
||||||
|
|||||||
@@ -94,6 +94,7 @@ export default {
|
|||||||
// Plugins to run before rendering page (https://go.nuxtjs.dev/config-plugins)
|
// Plugins to run before rendering page (https://go.nuxtjs.dev/config-plugins)
|
||||||
plugins: [
|
plugins: [
|
||||||
"~/plugins/v-tippy",
|
"~/plugins/v-tippy",
|
||||||
|
"~/plugins/v-focus",
|
||||||
"~/plugins/vuex-persist",
|
"~/plugins/vuex-persist",
|
||||||
"~/plugins/vue-rx",
|
"~/plugins/vue-rx",
|
||||||
"~/plugins/vue-apollo",
|
"~/plugins/vue-apollo",
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
<input
|
<input
|
||||||
id="url"
|
id="url"
|
||||||
v-model="url"
|
v-model="url"
|
||||||
|
v-focus
|
||||||
type="url"
|
type="url"
|
||||||
spellcheck="false"
|
spellcheck="false"
|
||||||
class="
|
class="
|
||||||
|
|||||||
7
plugins/v-focus.js
Normal file
7
plugins/v-focus.js
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
import Vue from "vue"
|
||||||
|
|
||||||
|
Vue.directive("focus", {
|
||||||
|
inserted: (el) => {
|
||||||
|
Vue.nextTick(() => el.focus())
|
||||||
|
},
|
||||||
|
})
|
||||||
Reference in New Issue
Block a user