Skip to content

Commit e234ef7

Browse files
committed
move over to vmodel instead of update
1 parent 0d3dcc7 commit e234ef7

2 files changed

Lines changed: 13 additions & 5 deletions

File tree

bcap/src/bcap/apps/Permit/components/dashboard/InternalDashboard.test.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,18 @@ describe('filter switching', () => {
282282
});
283283

284284
describe('search filtering', () => {
285+
it('feeds the term back to the toolbar, so the input keeps what was typed', async () => {
286+
getInternalDashboardData.mockResolvedValue([makeCard({ id: 'a' })]);
287+
const wrapper = mountDashboard();
288+
await flushPromises();
289+
290+
await emitFromToolbar(wrapper, 'update:search', 'copper');
291+
292+
expect(
293+
wrapper.findComponent({ name: 'SortingBar' }).props('search'),
294+
).toBe('copper');
295+
});
296+
285297
it('keeps only cards whose title matches the search term', async () => {
286298
getInternalDashboardData.mockResolvedValue([
287299
makeCard({ id: 'a', project_name: 'Copper Mine' }),

bcap/src/bcap/apps/Permit/components/dashboard/InternalDashboard.vue

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -152,10 +152,6 @@ const loadData = async () => {
152152
}
153153
};
154154
155-
function handleSearch(searchTerm: string) {
156-
state.currentSearch = searchTerm;
157-
}
158-
159155
const displayedProjects = computed(() => {
160156
let filtered = state.rawProjects;
161157
@@ -257,13 +253,13 @@ const onCardClick = (event: MouseEvent, item: ProjectData) => {
257253
v-model:current-sort="state.currentSort"
258254
v-model:sort-order="state.sortOrder"
259255
v-model:messages-only="state.messagesOnly"
256+
v-model:search="state.currentSearch"
260257
:tabs="internalTabs"
261258
:last-updated="state.lastUpdateDate"
262259
:sort-options="sortOptions"
263260
messages-only-label="Unread messages only"
264261
:shown="state.isLoading ? 0 : displayedProjects.length"
265262
:total="state.isLoading ? 0 : state.rawProjects.length"
266-
@update:search="handleSearch"
267263
@refresh="loadData"
268264
/>
269265

0 commit comments

Comments
 (0)