Skip to content

Commit

Permalink
fix(pagination): fix incorrect trigger onCurrentChange event (#3511)
Browse files Browse the repository at this point in the history
  • Loading branch information
Zz-ZzzZ authored Oct 26, 2023
1 parent 38f9378 commit d108380
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/pagination/pagination.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { defineComponent, computed, ref, watch, toRefs } from 'vue';
import { defineComponent, computed, ref, watch, toRefs, getCurrentInstance } from 'vue';
import isNaN from 'lodash/isNaN';
import {
PageFirstIcon as TdPageFirstIcon,
Expand Down Expand Up @@ -30,6 +30,8 @@ export default defineComponent({
props,

setup(props: TdPaginationProps) {
const { emit } = getCurrentInstance();

const { modelValue, pageSize, current } = toRefs(props);
const renderTNodeJSX = useTNodeJSX();
const [innerCurrent, setInnerCurrent] = useVModel(
Expand Down Expand Up @@ -151,9 +153,13 @@ export default defineComponent({
previous: prev,
pageSize: innerPageSize.value,
};
setInnerCurrent(current, pageInfo);

if (isTriggerChange !== false) {
setInnerCurrent(current, pageInfo);
props.onChange?.(pageInfo);
} else {
// 非主动更改时应仅更新modelValue不触发onCurrentChange事件
emit('update:modelValue', current);
}
}
};
Expand Down

0 comments on commit d108380

Please sign in to comment.