Skip to content

Commit 1f28877

Browse files
committed
Fixing typescript typings
Added debounce for filter component
1 parent bf10b6f commit 1f28877

File tree

4 files changed

+31
-7
lines changed

4 files changed

+31
-7
lines changed

src/Frontend/package-lock.json

Lines changed: 15 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Frontend/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
"bootstrap": "^5.3.3",
2727
"bootstrap-icons": "^1.11.3",
2828
"codemirror": "^6.0.1",
29+
"lodash.debounce": "^4.0.8",
2930
"lossless-json": "^4.0.2",
3031
"memoize-one": "^6.0.0",
3132
"moment": "^2.30.1",
@@ -48,6 +49,7 @@
4849
"@testing-library/vue": "^8.1.0",
4950
"@tsconfig/node18": "^18.2.4",
5051
"@types/bootstrap": "^5.2.10",
52+
"@types/lodash": "^4.17.16",
5153
"@types/node": "^22.13.10",
5254
"@vitejs/plugin-vue": "^5.2.3",
5355
"@vitest/coverage-v8": "^3.0.9",

src/Frontend/src/components/FilterInput.vue

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,23 @@
11
<script setup lang="ts">
2+
import { ref, watch } from "vue";
3+
import debounce from "lodash/debounce";
4+
25
const model = defineModel<string>({ required: true });
3-
defineProps({
4-
placeholder: {
5-
type: String,
6-
default: "Filter by name...", // Default value
7-
},
6+
const props = withDefaults(defineProps<{ placeholder?: string; ariaLabel?: string }>(), { placeholder: "Filter by name...", ariaLabel: "filter by name" });
7+
const localInput = ref<string>(model.value);
8+
9+
const debounceUpdateModel = debounce((value: string) => {
10+
model.value = value;
11+
}, 600);
12+
13+
watch(localInput, (newValue) => {
14+
debounceUpdateModel(newValue);
815
});
916
</script>
1017

1118
<template>
1219
<div role="search" aria-label="filter" class="filter-input">
13-
<input type="search" :placeholder="placeholder" aria-label="filter by name" class="form-control-static filter-input" v-model="model" />
20+
<input type="search" :placeholder="props.placeholder" :aria-label="ariaLabel" class="form-control-static filter-input" v-model="localInput" />
1421
</div>
1522
</template>
1623

src/Frontend/src/components/messages/HeadersView.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ const filteredHeaders = computed(() => {
2828
<div class="text-search-container">
2929
<div class="text-search">
3030
<div class="filter-group">
31-
<FilterInput v-model="searchTerm" aria-label="Filter by name" :placeholder="'Search for a header key or value...'" />
31+
<FilterInput v-model="searchTerm" :aria-label="`Search for a header key or value`" :placeholder="'Search for a header key or value...'" />
3232
</div>
3333
</div>
3434
</div>

0 commit comments

Comments
 (0)