From 49604e57de31c200e39d052a2f36c6308c37d70b Mon Sep 17 00:00:00 2001 From: saki Date: Thu, 13 Nov 2025 09:52:35 +0900 Subject: [PATCH] add onCloseCallback to useSearchDialog for better focus management --- src/components/AppLayout.vue | 4 +++- src/composables/useSearchDialog.ts | 5 ++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/components/AppLayout.vue b/src/components/AppLayout.vue index 24080b7..fe888aa 100644 --- a/src/components/AppLayout.vue +++ b/src/components/AppLayout.vue @@ -26,7 +26,9 @@ const editorInstance = ref(undefined) provide('editorInstance', editorInstance) const { isOpenBuiltInAiPanel, toggleBuiltInAiPanel } = useBuiltInAi() -const searchDialog = useSearchDialog() +const searchDialog = useSearchDialog(() => { + editorInstance.value?.commands.focus('end') +}) const handleAdd = async () => { const now = new Date().toISOString() diff --git a/src/composables/useSearchDialog.ts b/src/composables/useSearchDialog.ts index 576158b..072ecf1 100644 --- a/src/composables/useSearchDialog.ts +++ b/src/composables/useSearchDialog.ts @@ -3,13 +3,16 @@ import { store, commandMenuModifier } from '../store' const isOpenSearchDialog = ref(false) -export const useSearchDialog = () => { +export const useSearchDialog = (onCloseCallback?: () => void) => { const attachEventListeners = () => { document.addEventListener('keydown', handleKeyDown) document.addEventListener('keyup', handleKeyUp) } const closeSearchDialog = () => { isOpenSearchDialog.value = false + if (onCloseCallback) { + onCloseCallback() + } } const handleKeyDown = (e: KeyboardEvent) => { if (e.key === 'Escape') {