Skip to content

Commit eb8cd1c

Browse files
authored
Merge pull request #570 from sboldyreva/vuecomp-fix
Update ELSTechnology.vue: move activeTab reset out of computed getter
2 parents 524b856 + fd542dd commit eb8cd1c

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

docs/.vuepress/components/ELSTechnology.vue

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@
7474
</template>
7575

7676
<script setup>
77-
import { ref, computed } from "vue";
77+
import { ref, computed, watch } from "vue";
7878
7979
const search = ref("");
8080
const activeTab = ref(0);
@@ -1915,7 +1915,7 @@ const techData = [
19151915
19161916
const filteredData = computed(() => {
19171917
const term = search.value.toLowerCase();
1918-
const result = techData
1918+
return techData
19191919
.map((item) => {
19201920
const matchEcosystem = item.ecosystem.toLowerCase().includes(term);
19211921
const filteredProjects = item.projects.filter((p) =>
@@ -1933,11 +1933,13 @@ const filteredData = computed(() => {
19331933
};
19341934
})
19351935
.filter(Boolean);
1936+
});
19361937
1937-
// reset activeTab if out of range
1938+
// Reset the active tab when the filtered list changes and the current
1939+
// selection falls out of range. Handled as a side effect in response to
1940+
// dependency changes, keeping the computed getter above pure.
1941+
watch(filteredData, (result) => {
19381942
if (activeTab.value >= result.length) activeTab.value = 0;
1939-
1940-
return result;
19411943
});
19421944
19431945
function getFilteredProjects(item) {

0 commit comments

Comments
 (0)