timeline: focus on init (fix #932)

Signed-off-by: Varun Patil <radialapps@gmail.com>
pull/953/head
Varun Patil 2023-11-21 10:10:53 -08:00
parent 35d9df6f9c
commit 9cf852b780
3 changed files with 30 additions and 3 deletions

View File

@ -1,6 +1,7 @@
<template> <template>
<RecycleScroller <RecycleScroller
ref="recycler" ref="recycler"
tabindex="1"
type-field="cluster_type" type-field="cluster_type"
key-field="cluster_id" key-field="cluster_id"
class="grid-recycler hide-scrollbar-mobile" class="grid-recycler hide-scrollbar-mobile"
@ -14,7 +15,7 @@
@resize="resize" @resize="resize"
> >
<template #before> <template #before>
<slot name="before" /> <slot name="before"></slot>
</template> </template>
<template v-slot="{ item }"> <template v-slot="{ item }">
@ -61,6 +62,10 @@ export default defineComponent({
type: Boolean, type: Boolean,
default: false, default: false,
}, },
focus: {
type: Boolean,
default: false,
},
}, },
emits: { emits: {
@ -76,6 +81,15 @@ export default defineComponent({
this.resize(); this.resize();
}, },
watch: {
async items() {
if (this.focus) {
await this.$nextTick();
this.refs.recycler?.$el.focus();
}
},
},
computed: { computed: {
refs() { refs() {
return this.$refs as { return this.$refs as {
@ -160,10 +174,15 @@ export default defineComponent({
flex: 1; flex: 1;
max-height: 100%; max-height: 100%;
overflow-y: scroll !important; overflow-y: scroll !important;
&.empty { &.empty {
visibility: hidden; visibility: hidden;
} }
&:focus {
outline: none;
}
margin: 1px; margin: 1px;
@media (max-width: 768px) { @media (max-width: 768px) {
&.cluster--album { &.cluster--album {

View File

@ -6,7 +6,7 @@
<EmptyContent v-if="!items.length && !loading" /> <EmptyContent v-if="!items.length && !loading" />
<ClusterGrid :items="items" :minCols="minCols" :maxSize="maxSize"> <ClusterGrid :items="items" :minCols="minCols" :maxSize="maxSize" :focus="true">
<template #before> <template #before>
<DynamicTopMatter class="cv-dtm" ref="dtm" /> <DynamicTopMatter class="cv-dtm" ref="dtm" />
</template> </template>
@ -85,7 +85,7 @@ export default defineComponent({
watch: { watch: {
async $route(to: Route, from: Route) { async $route(to: Route, from: Route) {
if (to.path === from.path) return; if (to.path === from.path) return;
this.refresh(); await this.refresh();
}, },
}, },

View File

@ -19,6 +19,7 @@
<RecycleScroller <RecycleScroller
ref="recycler" ref="recycler"
class="recycler hide-scrollbar" class="recycler hide-scrollbar"
tabindex="1"
:class="{ empty }" :class="{ empty }"
:items="list" :items="list"
:emit-update="true" :emit-update="true"
@ -274,6 +275,9 @@ export default defineComponent({
// Always do a hard refresh if the path changes // Always do a hard refresh if the path changes
if (from?.path !== to.path) { if (from?.path !== to.path) {
await this.refresh(); await this.refresh();
// Focus on the recycler (e.g. after navigation click)
this.refs.recycler?.$el.focus();
} }
// Do a soft refresh if the query changes // Do a soft refresh if the query changes
@ -1436,6 +1440,10 @@ export default defineComponent({
transition: none; transition: none;
width: 0; width: 0;
} }
&:focus {
outline: none;
}
} }
.recycler .photo { .recycler .photo {