@datagouv/components-next 1.0.2-dev.121 → 1.0.2-dev.123
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{Datafair.client-BrQPObQE.js → Datafair.client-DMmJ6GZp.js} +1 -1
- package/dist/{JsonPreview.client-1IGVQ08V.js → JsonPreview.client-BJl0ckqf.js} +2 -2
- package/dist/{MapContainer.client-CZzHdzlZ.js → MapContainer.client-BOILtnvJ.js} +2 -2
- package/dist/{PdfPreview.client-DqQGGYo_.js → PdfPreview.client-D7YzJBjf.js} +2 -2
- package/dist/{Pmtiles.client-BARkmNXd.js → Pmtiles.client-DYui1P0X.js} +1 -1
- package/dist/{PreviewWrapper.vue_vue_type_script_setup_true_lang-BVXRRGR-.js → PreviewWrapper.vue_vue_type_script_setup_true_lang-B1hQo45t.js} +1 -1
- package/dist/{XmlPreview.client-BaVAAiZe.js → XmlPreview.client-CNBElgL_.js} +3 -3
- package/dist/components-next.js +1 -1
- package/dist/{index-C8S0AX5n.js → index-O6jmaKXj.js} +1 -1
- package/dist/{leaflet-src-CTUz9_o9.js → leaflet-src-KM7yab2d.js} +1 -1
- package/dist/{main-BpO1p4v0.js → main-B40Z2ZUX.js} +1313 -1310
- package/dist/{vue3-xml-viewer.common-BmpkRVgr.js → vue3-xml-viewer.common-DPhRUkLi.js} +1 -1
- package/package.json +1 -1
- package/src/components/Search/GlobalSearch.vue +16 -2
- package/src/composables/useSearchFilter.ts +7 -5
package/package.json
CHANGED
|
@@ -549,20 +549,34 @@ const allFilters: Record<string, Ref<unknown>> = {
|
|
|
549
549
|
type: reuseType,
|
|
550
550
|
}
|
|
551
551
|
|
|
552
|
-
// Reset sort and filters when changing type
|
|
552
|
+
// Reset page, sort and filters when changing type. Every reset below goes
|
|
553
|
+
// through useRouteQuery, so VueUse coalesces them into a single router.replace
|
|
554
|
+
// (its shared _queriesQueue flushes once on nextTick). Custom filters are cleared
|
|
555
|
+
// here too, rather than in useSearchFilter's onunmount, so their URL change joins
|
|
556
|
+
// that same batch instead of racing it with a separate router.replace.
|
|
553
557
|
watch(currentType, () => {
|
|
558
|
+
// page=1 is the default and is dropped from the URL, so only reset when needed.
|
|
559
|
+
if (page.value !== 1) page.value = 1
|
|
560
|
+
|
|
554
561
|
// Reset sort if not valid
|
|
555
562
|
const validSortValues = activeSortOptions.value.map(o => o.value as string)
|
|
556
563
|
if (sort.value && !validSortValues.includes(sort.value)) {
|
|
557
564
|
sort.value = undefined
|
|
558
565
|
}
|
|
559
566
|
|
|
560
|
-
// Reset filters that are not enabled for the new type
|
|
567
|
+
// Reset built-in filters that are not enabled for the new type
|
|
561
568
|
for (const [filterName, filterRef] of Object.entries(allFilters)) {
|
|
562
569
|
if (filterRef.value !== undefined && !activeFilters.value.includes(filterName)) {
|
|
563
570
|
filterRef.value = undefined
|
|
564
571
|
}
|
|
565
572
|
}
|
|
573
|
+
|
|
574
|
+
// Reset type-scoped custom filters that don't apply to the new type
|
|
575
|
+
for (const entry of customFilterRegistry.values()) {
|
|
576
|
+
if (entry.typeKeys && !entry.typeKeys.includes(currentType.value) && isCustomFilterActive(entry)) {
|
|
577
|
+
entry.ref.value = entry.defaultValue
|
|
578
|
+
}
|
|
579
|
+
}
|
|
566
580
|
})
|
|
567
581
|
|
|
568
582
|
// Create stable params for each type
|
|
@@ -94,10 +94,12 @@ export function useSearchFilter(
|
|
|
94
94
|
})
|
|
95
95
|
|
|
96
96
|
onScopeDispose(() => {
|
|
97
|
-
//
|
|
98
|
-
//
|
|
99
|
-
//
|
|
100
|
-
//
|
|
97
|
+
// Type-scoped filters (typeKeys set) are cleared by GlobalSearch's
|
|
98
|
+
// watch(currentType) instead, so their URL update batches with the other
|
|
99
|
+
// type-change resets via useRouteQuery rather than racing them with the
|
|
100
|
+
// separate router.replace below. Here we only clear filters that apply to
|
|
101
|
+
// all types: their unmount is a consumer signal unrelated to a type switch,
|
|
102
|
+
// which GlobalSearch has no way to detect.
|
|
101
103
|
//
|
|
102
104
|
// We cannot use `value.value = defaultValue` here because VueUse's
|
|
103
105
|
// useRouteQuery registers its own tryOnScopeDispose cleanup that zeroes
|
|
@@ -105,7 +107,7 @@ export function useSearchFilter(
|
|
|
105
107
|
// The setter then sees `query === v` and early-returns without ever
|
|
106
108
|
// calling router.replace(). Instead we read the live route.query directly
|
|
107
109
|
// (which is router state, not affected by that cleanup) and push the update.
|
|
108
|
-
if (route.query[urlParam] !== undefined) {
|
|
110
|
+
if (normalizedTypeKeys === undefined && route.query[urlParam] !== undefined) {
|
|
109
111
|
const { [urlParam]: _removed, ...restQuery } = route.query
|
|
110
112
|
router.replace({
|
|
111
113
|
query: defaultValue === undefined ? restQuery : { ...restQuery, [urlParam]: String(defaultValue) },
|