Skip to content

πŸ”₯ πŸ”₯ πŸ”₯ A Free & Self-hostable Airtable Alternative

fix: baselist modal search input auto focus issue on performing any base action

Ramesh Mane3cafb84fc55e
diff --git a/packages/nc-gui/components/workspace/BaseListModal/index.vue b/packages/nc-gui/components/workspace/BaseListModal/index.vue
index cf61ed9332..f67744de5d 100644
--- a/packages/nc-gui/components/workspace/BaseListModal/index.vue
+++ b/packages/nc-gui/components/workspace/BaseListModal/index.vue
@@ -27,8 +27,7 @@ const closeModal = () => {
}
const { dialogState } = useProvideBaseActions(closeModal)
-// Autofocus search input
-const focus: VNodeRef = (el) => el?.focus()
+const searchInputRef = ref<HTMLInputElement>()
// Responsive state
const windowWidth = ref(typeof window !== 'undefined' ? window.innerWidth : 1024)
@@ -71,6 +70,18 @@ watch(visible, (isVisible) => {
}
})
+watch(
+ searchInputRef,
+ () => {
+ if (!searchInputRef.value) return
+
+ searchInputRef.value.focus()
+ },
+ {
+ immediate: true,
+ },
+)
+
const workspaceBases = computed(() => {
return basesList.value
})
@@ -168,7 +179,7 @@ const hasNoSearchResults = computed(() => {
class="flex items-center px-4 py-3 border-b border-nc-border-gray-medium dark:bg-nc-bg-gray-extralight"
>
<a-input
- :ref="focus"
+ ref="searchInputRef"
v-model:value="modalState.searchQuery"
class="nc-workspace-base-search"
:placeholder="$t('placeholder.searchWorkspacesAndBases')"