diff --git a/src/list/List.tsx b/src/list/List.tsx index 447c271b9..b42508c14 100644 --- a/src/list/List.tsx +++ b/src/list/List.tsx @@ -139,6 +139,14 @@ export default defineComponent({ check ); + if (tabStatus) { + watch(tabStatus, (tabActive) => { + if (tabActive) { + check(); + } + }); + } + onUpdated(() => { loading.value = props.loading!; }); diff --git a/src/list/test/index.spec.js b/src/list/test/index.spec.js index a53348019..2cd336967 100644 --- a/src/list/test/index.spec.js +++ b/src/list/test/index.spec.js @@ -158,3 +158,38 @@ test('should not emit load event when inside an inactive tab', async () => { expect(onLoad1).toHaveBeenCalledTimes(1); expect(onLoad2).toHaveBeenCalledTimes(0); }); + +// https://github.com/youzan/vant/issues/9017 +test('should emit load event when parent tab is activated', async () => { + const onLoad1 = jest.fn(); + const onLoad2 = jest.fn(); + + const wrapper = mount({ + data() { + return { + active: 0, + }; + }, + render() { + return ( + + + + + + + + + ); + }, + }); + + await later(); + expect(onLoad1).toHaveBeenCalledTimes(1); + expect(onLoad2).toHaveBeenCalledTimes(0); + + await wrapper.setData({ active: 1 }); + await later(); + expect(onLoad1).toHaveBeenCalledTimes(1); + expect(onLoad2).toHaveBeenCalledTimes(1); +});