fix: modal shift on close + readd settings preload (#6448)

* fix: NewModal layout shift on close

* fix: preload queries in settings modals

* fix: any
This commit is contained in:
Calum H.
2026-06-19 20:23:35 +00:00
committed by GitHub
parent ac5daad280
commit 56536abb24
9 changed files with 178 additions and 91 deletions
@@ -268,6 +268,7 @@ function hide() {
return
}
props.onHide?.()
resetMousePosition()
visible.value = false
popModal()
if (modalStackSize() === 0) {
@@ -309,6 +310,11 @@ function updateMousePosition(event: { clientX: number; clientY: number }) {
mouseY.value = event.clientY
}
function resetMousePosition() {
mouseX.value = Math.round(window.innerWidth / 2)
mouseY.value = Math.round(window.innerHeight / 2)
}
onUnmounted(() => {
if (open.value) {
popModal()
@@ -325,8 +331,6 @@ function handleWindowKeyDown(event: KeyboardEvent) {
if (props.closeOnEsc && event.key === 'Escape' && props.closable) {
if (!isTopmostModal()) return
hide()
mouseX.value = Math.round(window.innerWidth / 2)
mouseY.value = Math.round(window.innerHeight / 2)
}
}
@@ -1,7 +1,7 @@
<script setup lang="ts">
import type { Archon } from '@modrinth/api-client'
import { ChevronRightIcon } from '@modrinth/assets'
import { useQueryClient } from '@tanstack/vue-query'
import { useQuery, useQueryClient } from '@tanstack/vue-query'
import { computed, nextTick, ref } from 'vue'
import type { TabbedModalTab } from '#ui/components'
@@ -60,6 +60,16 @@ const currentUserRole = ref<string | null>(null)
const isApp = ref(true)
// Preload
useQuery({
queryKey: computed(() => ['content', 'list', 'v1', currentServerId]),
queryFn: () =>
client.archon.content_v1.getAddons(currentServerId, worldId.value!, {
from_modpack: false,
}),
enabled: computed(() => !!worldId.value),
})
const serverSettingsTabComponentMap = {
general: ServerSettingsGeneralPage,
installation: ServerSettingsInstallationPage,
@@ -185,13 +195,6 @@ async function show({ serverId, tabIndex, tabId }: ShowOptions) {
queryKey: ['servers', 'properties', 'v1', targetServerId, worldId.value],
queryFn: () => client.archon.properties_v1.getProperties(targetServerId, worldId.value!),
})
queryClient.prefetchQuery({
queryKey: ['content', 'list', 'v1', targetServerId],
queryFn: () =>
client.archon.content_v1.getAddons(targetServerId, worldId.value!, {
from_modpack: false,
}),
})
queryClient.prefetchQuery({
queryKey: ['servers', 'startup', 'v1', targetServerId, worldId.value],
queryFn: () => client.archon.options_v1.getStartup(targetServerId, worldId.value!),