Compare commits

...

7 Commits

Author SHA1 Message Date
neverland
8bc55c8b32
fix(TreeSelect): click-nav event not work when clicking active item (#10239) 2022-01-25 11:44:05 +08:00
chenjiahan
c7cc1342fc release: @vant/area-data 1.2.2 2022-01-25 11:16:11 +08:00
neverland
3e197222c1
fix(@vant/area-data): update county of xingtai (#10236) 2022-01-25 11:15:11 +08:00
dependabot[bot]
acb4364c97
build(deps): bump node-fetch from 2.6.6 to 2.6.7 in /packages/vant-icons (#10237)
Bumps [node-fetch](https://github.com/node-fetch/node-fetch) from 2.6.6 to 2.6.7.
- [Release notes](https://github.com/node-fetch/node-fetch/releases)
- [Commits](https://github.com/node-fetch/node-fetch/compare/v2.6.6...v2.6.7)

---
updated-dependencies:
- dependency-name: node-fetch
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-01-25 11:14:44 +08:00
chenjiahan
52ed563d46 docs(@vant/use): changelog 1.3.5 2022-01-25 11:09:13 +08:00
chenjiahan
1d69e73eda release: @vant/use 1.3.5 2022-01-25 11:07:27 +08:00
neverland
760fcbb424
fix(@vant/use): missing subTree when flattening vnodes (#10235) 2022-01-25 10:59:04 +08:00
9 changed files with 52 additions and 29 deletions

View File

@ -1,6 +1,6 @@
{
"name": "@vant/area-data",
"version": "1.2.1",
"version": "1.2.2",
"description": "Vant 省市区数据",
"main": "dist/index.cjs.js",
"module": "dist/index.esm.js",

View File

@ -509,15 +509,14 @@ export const areaList = {
130471: '邯郸经济技术开发区',
130473: '邯郸冀南新区',
130481: '武安市',
130502: '桥东区',
130503: '桥西区',
130521: '邢台县',
130502: '襄都区',
130503: '信都区',
130505: '任泽区',
130506: '南和区',
130522: '临城县',
130523: '内丘县',
130524: '柏乡县',
130525: '隆尧县',
130526: '任县',
130527: '南和县',
130528: '宁晋县',
130529: '巨鹿县',
130530: '新河县',

View File

@ -1281,9 +1281,9 @@ new-github-release-url@1.0.0:
type-fest "^0.4.1"
node-fetch@^2.6.1:
version "2.6.6"
resolved "https://registry.npmmirror.com/node-fetch/download/node-fetch-2.6.6.tgz#1751a7c01834e8e1697758732e9efb6eeadfaf89"
integrity sha1-F1GnwBg06OFpd1hzLp77burfr4k=
version "2.6.7"
resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.7.tgz#24de9fba827e3b4ae44dc8b20256a379160052ad"
integrity sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ==
dependencies:
whatwg-url "^5.0.0"
@ -1794,7 +1794,7 @@ to-regex-range@^5.0.1:
tr46@~0.0.3:
version "0.0.3"
resolved "https://registry.npmmirror.com/tr46/download/tr46-0.0.3.tgz?cache=0&sync_timestamp=1633303287861&other_urls=https%3A%2F%2Fregistry.npmmirror.com%2Ftr46%2Fdownload%2Ftr46-0.0.3.tgz#8184fd347dac9cdc185992f3a6622e14b9d9ab6a"
resolved "https://registry.yarnpkg.com/tr46/-/tr46-0.0.3.tgz#8184fd347dac9cdc185992f3a6622e14b9d9ab6a"
integrity sha1-gYT9NH2snNwYWZLzpmIuFLnZq2o=
tslib@~2.1.0:
@ -1887,12 +1887,12 @@ wcwidth@^1.0.1:
webidl-conversions@^3.0.0:
version "3.0.1"
resolved "https://registry.npmmirror.com/webidl-conversions/download/webidl-conversions-3.0.1.tgz?cache=0&sync_timestamp=1632753508689&other_urls=https%3A%2F%2Fregistry.npmmirror.com%2Fwebidl-conversions%2Fdownload%2Fwebidl-conversions-3.0.1.tgz#24534275e2a7bc6be7bc86611cc16ae0a5654871"
resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-3.0.1.tgz#24534275e2a7bc6be7bc86611cc16ae0a5654871"
integrity sha1-JFNCdeKnvGvnvIZhHMFq4KVlSHE=
whatwg-url@^5.0.0:
version "5.0.0"
resolved "https://registry.npmmirror.com/whatwg-url/download/whatwg-url-5.0.0.tgz#966454e8765462e37644d3626f6742ce8b70965d"
resolved "https://registry.yarnpkg.com/whatwg-url/-/whatwg-url-5.0.0.tgz#966454e8765462e37644d3626f6742ce8b70965d"
integrity sha1-lmRU6HZUYuN2RNNib2dCzotwll0=
dependencies:
tr46 "~0.0.3"

View File

@ -1,5 +1,9 @@
# Changelog
## v1.3.5
- Fix useChildren missing subTree when flattening vnodes
## v1.3.4
- Fix useClickAway failed in SSR

View File

@ -1,6 +1,6 @@
{
"name": "@vant/use",
"version": "1.3.4",
"version": "1.3.5",
"description": "Vant Composition API",
"main": "dist/index.cjs.js",
"module": "dist/index.esm.js",

View File

@ -20,6 +20,7 @@ export function flattenVNodes(children: VNodeNormalizedChildren) {
result.push(child);
if (child.component?.subTree) {
result.push(child.component.subTree);
traverse(child.component.subTree.children);
}

View File

@ -15,7 +15,7 @@ exports[`should render Tab inside a component correctly 1`] = `
aria-controls="van-tab"
>
<span class="van-tab__text van-tab__text--ellipsis">
2
1
</span>
</div>
<div id="van-tabs-1"
@ -26,7 +26,7 @@ exports[`should render Tab inside a component correctly 1`] = `
aria-controls="van-tab"
>
<span class="van-tab__text van-tab__text--ellipsis">
1
2
</span>
</div>
<div id="van-tabs-2"
@ -47,15 +47,6 @@ exports[`should render Tab inside a component correctly 1`] = `
</div>
</div>
<div class="van-tabs__content">
<div id="van-tab"
role="tabpanel"
class="van-tab__panel"
tabindex="0"
aria-labelledby="van-tabs-1"
style
>
1
</div>
<div id="van-tab"
role="tabpanel"
class="van-tab__panel"
@ -64,6 +55,15 @@ exports[`should render Tab inside a component correctly 1`] = `
style="display: none;"
>
</div>
<div id="van-tab"
role="tabpanel"
class="van-tab__panel"
tabindex="0"
aria-labelledby="van-tabs-1"
style
>
2
</div>
<div id="van-tab"
role="tabpanel"
class="van-tab__panel"

View File

@ -112,9 +112,10 @@ export default defineComponent({
const onSidebarChange = (index: number) => {
emit('update:mainActiveIndex', index);
emit('click-nav', index);
};
const onClickSidebarItem = (index: number) => emit('click-nav', index);
const renderSidebar = () => {
const Items = props.items.map((item) => (
<SidebarItem
@ -123,6 +124,7 @@ export default defineComponent({
badge={item.badge}
class={[bem('nav-item'), item.className]}
disabled={item.disabled}
onClick={onClickSidebarItem}
/>
));

View File

@ -26,7 +26,23 @@ test('should render empty TreeSelect correctly', () => {
expect(mount(TreeSelect).html()).toMatchSnapshot();
});
test('should emit click-nav event when nav item is clicked', () => {
test('should emit update:mainActiveIndex event when mainActiveIndex is changed', async () => {
const wrapper = mount(TreeSelect, {
props: {
items: mockItems,
mainActiveIndex: 0,
},
});
const navItems = wrapper.findAll('.van-tree-select__nav-item');
await navItems[0].trigger('click');
expect(wrapper.emitted('update:mainActiveIndex')).toBeFalsy();
await navItems[1].trigger('click');
expect(wrapper.emitted('update:mainActiveIndex')?.[0]).toEqual([1]);
});
test('should emit click-nav event when nav item is clicked', async () => {
const wrapper = mount(TreeSelect, {
props: {
items: mockItems,
@ -34,9 +50,10 @@ test('should emit click-nav event when nav item is clicked', () => {
});
const navItems = wrapper.findAll('.van-tree-select__nav-item');
navItems[1].trigger('click');
expect(wrapper.emitted('update:mainActiveIndex')?.[0]).toEqual([1]);
expect(wrapper.emitted('click-nav')?.[0]).toEqual([1]);
await navItems[0].trigger('click');
expect(wrapper.emitted('click-nav')?.[0]).toEqual([0]);
await navItems[0].trigger('click');
expect(wrapper.emitted('click-nav')?.[1]).toEqual([0]);
});
test('should emit click-item event when item is clicked', () => {