Skip to content

Commit

Permalink
feat(inputs): add better autofocus (filebrowser#26)
Browse files Browse the repository at this point in the history
fix issue filebrowser#25
  • Loading branch information
hugomassing authored and hacdias committed Aug 6, 2018
1 parent 208f217 commit 157b2da
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 12 deletions.
10 changes: 5 additions & 5 deletions src/components/prompts/Download.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
<div class="card-content">
<p>{{ $t('prompts.downloadMessage') }}</p>

<button class="block cancel" @click="download('zip')" autofocus>zip</button>
<button class="block cancel" @click="download('tar')" autofocus>tar</button>
<button class="block cancel" @click="download('targz')" autofocus>tar.gz</button>
<button class="block cancel" @click="download('tarbz2')" autofocus>tar.bz2</button>
<button class="block cancel" @click="download('tarxz')" autofocus>tar.xz</button>
<button class="block cancel" @click="download('zip')" v-focus>zip</button>
<button class="block cancel" @click="download('tar')" v-focus>tar</button>
<button class="block cancel" @click="download('targz')" v-focus>tar.gz</button>
<button class="block cancel" @click="download('tarbz2')" v-focus>tar.bz2</button>
<button class="block cancel" @click="download('tarxz')" v-focus>tar.xz</button>
</div>
</div>
</template>
Expand Down
2 changes: 1 addition & 1 deletion src/components/prompts/NewArchetype.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<div class="card-content">
<p>{{ $t('prompts.newArchetype') }}</p>
<input autofocus type="text" @keyup.enter="submit" v-model.trim="name">
<input v-focus type="text" @keyup.enter="submit" v-model.trim="name">
<input type="text" @keyup.enter="submit" v-model.trim="archetype">
</div>

Expand Down
2 changes: 1 addition & 1 deletion src/components/prompts/NewDir.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<div class="card-content">
<p>{{ $t('prompts.newDirMessage') }}</p>
<input autofocus type="text" @keyup.enter="submit" v-model.trim="name">
<input type="text" @keyup.enter="submit" v-model.trim="name" v-focus >
</div>

<div class="card-action">
Expand Down
2 changes: 1 addition & 1 deletion src/components/prompts/NewFile.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<div class="card-content">
<p>{{ $t('prompts.newFileMessage') }}</p>
<input autofocus type="text" @keyup.enter="submit" v-model.trim="name">
<input v-focus type="text" @keyup.enter="submit" v-model.trim="name">
</div>

<div class="card-action">
Expand Down
2 changes: 1 addition & 1 deletion src/components/prompts/Rename.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<div class="card-content">
<p>{{ $t('prompts.renameMessage') }} <code>{{ oldName() }}</code>:</p>
<input autofocus type="text" @keyup.enter="submit" v-model.trim="name">
<input v-focus type="text" @keyup.enter="submit" v-model.trim="name">
</div>

<div class="card-action">
Expand Down
2 changes: 1 addition & 1 deletion src/components/prompts/Schedule.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<div class="card-content">
<p>{{ $t('prompts.scheduleMessage') }}</p>
<input autofocus type="datetime-local" v-model="date">
<input v-focus type="datetime-local" v-model="date">
</div>

<div class="card-action">
Expand Down
2 changes: 1 addition & 1 deletion src/components/prompts/Share.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
</li>

<li>
<input autofocus
<input v-focus
type="number"
max="2147483647"
min="0"
Expand Down
6 changes: 6 additions & 0 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ Vue.prototype.$showError = function (error) {
n.show()
}

Vue.directive('focus', {
inserted: function (el) {
el.focus()
}
})

/* eslint-disable no-new */
new Vue({
el: '#app',
Expand Down
2 changes: 1 addition & 1 deletion src/views/settings/User.vue
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
<div class="card-action">
<button class="cancel flat"
@click="closeHovers"
autofocus
v-focus
:aria-label="$t('buttons.cancel')"
:title="$t('buttons.cancel')">
{{ $t('buttons.cancel') }}
Expand Down

0 comments on commit 157b2da

Please sign in to comment.