From a7f466a9cae77ff79ce092cb42a202514150a289 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexandre=20Bult=C3=A9?= Date: Mon, 25 May 2026 13:35:19 +0200 Subject: [PATCH 1/3] feat(search): emit resultsCount --- .../src/components/Search/GlobalSearch.vue | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/datagouv-components/src/components/Search/GlobalSearch.vue b/datagouv-components/src/components/Search/GlobalSearch.vue index eb7ec1904..de603da75 100644 --- a/datagouv-components/src/components/Search/GlobalSearch.vue +++ b/datagouv-components/src/components/Search/GlobalSearch.vue @@ -406,6 +406,10 @@ const props = withDefaults(defineProps<{ hideSearchInput: false, }) +const emit = defineEmits<{ + resultsCount: [total: number] +}>() + // defineModel's default is static and can't depend on props, so we cast and initialize manually const currentType = defineModel('type') as Ref if (!currentType.value) currentType.value = configKey(props.config[0] ?? { class: 'datasets' }) @@ -717,6 +721,10 @@ function resetFilters() { const searchResults = computed(() => resultsMap[currentType.value]?.data.value) const searchResultsStatus = computed(() => resultsMap[currentType.value]?.status.value) +watch(searchResults, (results) => { + if (results) emit('resultsCount', results.total) +}, { immediate: true }) + // RSS feed URL for datasets const rssUrl = computed(() => { if (currentTypeConfig.value?.class !== 'datasets') return null From 1b59ae93e7a4aee6eac6a27bc3a47ec8dc826c28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexandre=20Bult=C3=A9?= Date: Mon, 25 May 2026 13:59:44 +0200 Subject: [PATCH 2/3] fix(a11y): optionnal auto-focus on input --- datagouv-components/src/components/Search/GlobalSearch.vue | 3 +++ datagouv-components/src/components/Search/SearchInput.vue | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/datagouv-components/src/components/Search/GlobalSearch.vue b/datagouv-components/src/components/Search/GlobalSearch.vue index de603da75..b8790b415 100644 --- a/datagouv-components/src/components/Search/GlobalSearch.vue +++ b/datagouv-components/src/components/Search/GlobalSearch.vue @@ -13,6 +13,7 @@
@@ -401,9 +402,11 @@ const props = withDefaults(defineProps<{ config?: GlobalSearchConfig placeholder?: string | null hideSearchInput?: boolean + autoFocus?: boolean }>(), { config: getDefaultGlobalSearchConfig, hideSearchInput: false, + autoFocus: true, }) const emit = defineEmits<{ diff --git a/datagouv-components/src/components/Search/SearchInput.vue b/datagouv-components/src/components/Search/SearchInput.vue index 3e5a902a2..de5a6e539 100644 --- a/datagouv-components/src/components/Search/SearchInput.vue +++ b/datagouv-components/src/components/Search/SearchInput.vue @@ -37,7 +37,7 @@ import BrandedButton from '../BrandedButton.vue' const q = defineModel({ required: true }) -withDefaults(defineProps<{ +const props = withDefaults(defineProps<{ placeholder?: string | null autoFocus?: boolean }>(), { @@ -57,6 +57,7 @@ const focus = () => { } onMounted(async () => { + if (!props.autoFocus) return await nextTick() focus() }) From 6b5cde4ded83685334a9bb01e0e18843c7e18ebe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexandre=20Bult=C3=A9?= Date: Tue, 26 May 2026 08:38:36 +0200 Subject: [PATCH 3/3] Update datagouv-components/src/components/Search/GlobalSearch.vue Co-authored-by: Thibaud Ollagnier --- datagouv-components/src/components/Search/GlobalSearch.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/datagouv-components/src/components/Search/GlobalSearch.vue b/datagouv-components/src/components/Search/GlobalSearch.vue index b8790b415..c36a89f02 100644 --- a/datagouv-components/src/components/Search/GlobalSearch.vue +++ b/datagouv-components/src/components/Search/GlobalSearch.vue @@ -13,7 +13,7 @@