Fix request/reports not filtering and form auto focussing on mounted when `autofocus` is `false`

This commit is contained in:
wvffle 2022-11-02 13:53:44 +00:00 committed by JuniorJPDJ
parent 66fd99c246
commit 8a1cdd27d5
4 changed files with 15 additions and 8 deletions

View File

@ -1,7 +1,7 @@
<script setup lang="ts">
import axios from 'axios'
import { useVModel, watchDebounced, useTextareaAutosize, syncRef } from '@vueuse/core'
import { ref, computed, watchEffect, onMounted, nextTick } from 'vue'
import { ref, computed, watchEffect, onMounted, nextTick, watch } from 'vue'
import { useGettext } from 'vue3-gettext'
interface Events {
@ -61,14 +61,15 @@ watchEffect(async () => {
if (value.value && !preview.value && !isLoadingPreview.value) {
await loadPreview()
}
return
}
await nextTick()
textarea.value.focus()
})
watch(isPreviewing, (to, from) => {
if (from === true) {
textarea.value.focus()
}
}, { flush: 'post' })
onMounted(async () => {
if (props.autofocus) {
await nextTick()

View File

@ -157,6 +157,7 @@ export default [
path: 'reports',
name: 'manage.moderation.reports.list',
component: () => import('~/views/admin/moderation/ReportsList.vue'),
props: route => ({ defaultQuery: route.query.q }),
meta: {
paginateBy: 25
}
@ -171,6 +172,7 @@ export default [
path: 'requests',
name: 'manage.moderation.requests.list',
component: () => import('~/views/admin/moderation/RequestsList.vue'),
props: route => ({ defaultQuery: route.query.q }),
meta: {
paginateBy: 25
}

View File

@ -25,11 +25,13 @@ interface Props extends SmartSearchProps, OrderingProps {
mode?: 'card'
// TODO(wvffle): Remove after https://github.com/vuejs/core/pull/4512 is merged
defaultQuery?: string
orderingConfigName?: RouteRecordName
updateUrl?: boolean
}
const props = withDefaults(defineProps<Props>(), {
defaultQuery: '',
updateUrl: false,
mode: 'card',
orderingConfigName: undefined
@ -81,7 +83,7 @@ const fetchData = async () => {
}
onSearch(() => (page.value = 1))
watch(page, fetchData)
watch([page, query], fetchData)
onOrderingUpdate(fetchData)
fetchData()

View File

@ -22,11 +22,13 @@ import usePage from '~/composables/navigation/usePage'
interface Props extends SmartSearchProps, OrderingProps {
// TODO(wvffle): Remove after https://github.com/vuejs/core/pull/4512 is merged
defaultQuery?: string
orderingConfigName?: RouteRecordName
updateUrl?: boolean
}
const props = withDefaults(defineProps<Props>(), {
defaultQuery: '',
updateUrl: false,
orderingConfigName: undefined
})
@ -77,7 +79,7 @@ const fetchData = async () => {
}
onSearch(() => (page.value = 1))
watch(page, fetchData)
watch([page, query], fetchData)
onOrderingUpdate(fetchData)
fetchData()