Skip to content

Commit

Permalink
fix: useTable reset page.index when data change
Browse files Browse the repository at this point in the history
  • Loading branch information
zuofenghua committed Apr 12, 2022
1 parent a8b284b commit ee752b9
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 13 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ahooks-vue",
"version": "0.12.8",
"version": "0.12.9",
"description": "ahooks-vue",
"types": "dist/src/index.d.ts",
"repository": "https://github.com/dewfall123/ahooks-vue.git",
Expand Down
8 changes: 3 additions & 5 deletions src/useTable/__tests__/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,13 @@ describe('useTable', () => {

expect(total.value).toEqual(1);
expect(
pagedData.value.every((item) =>
JSON.stringify(item).includes(searchText),
),
pagedData.value.every(item => JSON.stringify(item).includes(searchText)),
);

search.value.text === 'Jim Green';
await nextTick(() => {
expect(
pagedData.value.every((item) =>
pagedData.value.every(item =>
JSON.stringify(item).includes('Jim Green'),
),
);
Expand All @@ -81,7 +79,7 @@ describe('useTable', () => {
search.value.text = '39';
search.value.keys = ['age'];
await nextTick(() => {
expect(pagedData.value.every((item) => item.age === 39));
expect(pagedData.value.every(item => item.age === 39));
});
});
});
2 changes: 1 addition & 1 deletion src/useTable/demo/sort-icon.vue
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<template functional>
<template>
<svg
t="1603888743183"
class="icon"
Expand Down
10 changes: 4 additions & 6 deletions src/useTable/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,12 +132,10 @@ export function useTable<T>(
return list as T[];
});

watch(
() => data,
() => {
search.value.text = '';
},
);
watch([data], () => {
search.value.text = '';
page.value.index = 1;
});

watch(
() => page.value.size,
Expand Down

0 comments on commit ee752b9

Please sign in to comment.