Skip to content

Commit ace0192

Browse files
authored
Merge branch 'next' into hxy/715/uploader
2 parents 6e203f6 + 08a9af5 commit ace0192

File tree

18 files changed

+102
-50
lines changed

18 files changed

+102
-50
lines changed

CHANGELOG.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
# v2.6.14
2+
`2024-07-19`
3+
4+
5+
* :sparkles: feat(menuitem): 新增css类名,增强自定义样式能力 (#2443) @Alex-huxiyang
6+
* :sparkles: feat(empty): add css variable nutui-empty-background-color (#2451) @Alex-huxiyang
7+
* :sparkles: feat(infiniteLoading): 继承 scrollView 的 props 类型 (#2441) @oasis-cloud
8+
* :bug: fix(cascader): 初始化设置value未成功选中 (#2435) @Alex-huxiyang
9+
* :bug: fix(swiper): display abnormal when dir = 'rtl' (#2454) @Alex-huxiyang
10+
* :bug: fix(form): 兼容校验时机 (#2437) @Alex-huxiyang
11+
* :bug: fix(form): 在FromInstance增加validateFields方法的定义 (#2450) @jinjl
12+
13+
114
# v2.6.13
215
`2024-07-12`
316

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"name": "@nutui/nutui-react",
3-
"version": "2.6.13",
2+
"name": "@nutui/nutui-react-taro",
3+
"version": "2.6.14",
44
"style": "dist/style.css",
55
"main": "dist/nutui.react.umd.js",
66
"module": "dist/esm/nutui-react.es.js",

src/packages/calendaritem/calendaritem.taro.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -480,12 +480,14 @@ export const CalendarItem = React.forwardRef<
480480
monthsData.splice(0)
481481
initData()
482482
}
483-
484483
useEffect(() => {
485484
setCurrentDate(resetDefaultValue() || [])
486-
popup && resetRender()
487485
}, [defaultValue])
488486

487+
useEffect(() => {
488+
popup && resetRender()
489+
}, [currentDate])
490+
489491
// 暴露出的API
490492
const scrollToDate = (date: string) => {
491493
if (Utils.compareDate(date, propStartDate)) {

src/packages/calendaritem/calendaritem.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -483,9 +483,12 @@ export const CalendarItem = React.forwardRef<
483483

484484
useEffect(() => {
485485
setCurrentDate(resetDefaultValue() || [])
486-
popup && resetRender()
487486
}, [defaultValue])
488487

488+
useEffect(() => {
489+
popup && resetRender()
490+
}, [currentDate])
491+
489492
// 暴露出的API
490493
const scrollToDate = (date: string) => {
491494
if (Utils.compareDate(date, propStartDate)) {

src/packages/cascader/__tests__/cascader.spec.tsx

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,33 @@ describe('Cascader', () => {
321321
).toBe(0)
322322
expect(container).toMatchSnapshot()
323323
})
324-
324+
it('init Value without defaultValue', async () => {
325+
const { container } = render(
326+
<Cascader
327+
visible
328+
value={['福建', '福州', '鼓楼区']}
329+
options={mockOptions}
330+
/>
331+
)
332+
const element = container.querySelectorAll(
333+
'.active.nut-tabpane .active .nut-cascader-item-title'
334+
)[0]
335+
expect(element).toHaveTextContent('鼓楼区')
336+
})
337+
it('init Value with both valu and defaultValue', async () => {
338+
const { container } = render(
339+
<Cascader
340+
visible
341+
value={['福建', '福州', '台江区']}
342+
defaultValue={['福建', '福州', '鼓楼区']}
343+
options={mockOptions}
344+
/>
345+
)
346+
const element = container.querySelectorAll(
347+
'.active.nut-tabpane .active .nut-cascader-item-title'
348+
)[0]
349+
expect(element).toHaveTextContent('台江区')
350+
})
325351
it('select', async () => {
326352
const change = vi.fn()
327353
const pathChange = vi.fn()
@@ -377,13 +403,10 @@ describe('Cascader', () => {
377403
/>
378404
)
379405

380-
expect(container).toMatchSnapshot()
381-
382406
expect(container.querySelector('.nut-popup')).toBe
383407

384408
const tabPane = container.querySelectorAll('.nut-tabs-titles-item')[0]
385409
fireEvent.click(tabPane)
386-
expect(container).toMatchSnapshot()
387410
})
388411

389412
it('ref', async () => {

src/packages/cascader/cascader.taro.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ const InternalCascader: ForwardRefRenderFunction<
211211

212212
if (
213213
currentValue === undefined ||
214-
currentValue !== defaultValue ||
214+
![defaultValue, value].includes(currentValue) ||
215215
!state.tree.nodes.length
216216
) {
217217
return
@@ -252,7 +252,7 @@ const InternalCascader: ForwardRefRenderFunction<
252252
}
253253
}
254254

255-
if (needToSync.length && currentValue === defaultValue) {
255+
if (needToSync.length && [defaultValue, value].includes(currentValue)) {
256256
const pathNodes = state.tree.getPathNodesByValue(needToSync)
257257
pathNodes.forEach((node, index) => {
258258
state.tabsCursor = index

src/packages/cascader/cascader.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ const InternalCascader: ForwardRefRenderFunction<
210210

211211
if (
212212
currentValue === undefined ||
213-
currentValue !== defaultValue ||
213+
![defaultValue, value].includes(currentValue) ||
214214
!state.tree.nodes.length
215215
) {
216216
return
@@ -251,7 +251,7 @@ const InternalCascader: ForwardRefRenderFunction<
251251
}
252252
}
253253

254-
if (needToSync.length && currentValue === defaultValue) {
254+
if (needToSync.length && [defaultValue, value].includes(currentValue)) {
255255
const pathNodes = state.tree.getPathNodesByValue(needToSync)
256256
pathNodes.forEach((node, index) => {
257257
state.tabsCursor = index

src/packages/cascader/demos/h5/demo1.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,16 @@ const Demo1 = () => {
3838
text: '长沙',
3939
disabled: true,
4040
children: [
41-
{ value: '西湖区', text: '西湖区' },
42-
{ value: '余杭区', text: '余杭区' },
41+
{ value: '芙蓉区', text: '芙蓉区' },
42+
{ value: '岳麓区', text: '岳麓区' },
4343
],
4444
},
4545
{
46-
value: '温州',
47-
text: '温州',
46+
value: '岳阳',
47+
text: '岳阳',
4848
children: [
49-
{ value: '鹿城区', text: '鹿城区' },
50-
{ value: '瓯海区', text: '瓯海区' },
49+
{ value: '岳阳楼区', text: '岳阳楼区' },
50+
{ value: '云溪区', text: '云溪区' },
5151
],
5252
},
5353
],

src/packages/cascader/demos/h5/demo2.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,16 @@ const Demo2 = () => {
3838
text1: '长沙',
3939
disabled: true,
4040
items: [
41-
{ value1: '西湖区', text1: '西湖区' },
42-
{ value1: '余杭区', text1: '余杭区' },
41+
{ value1: '芙蓉区', text1: '芙蓉区' },
42+
{ value1: '岳麓区', text1: '岳麓区' },
4343
],
4444
},
4545
{
46-
value1: '温州',
47-
text1: '温州',
48-
items: [
49-
{ value1: '鹿城区', text1: '鹿城区' },
50-
{ value1: '瓯海区', text1: '瓯海区' },
46+
value1: '岳阳',
47+
text1: '岳阳',
48+
children: [
49+
{ value1: '岳阳楼区', text1: '岳阳楼区' },
50+
{ value1: '云溪区', text1: '云溪区' },
5151
],
5252
},
5353
],

src/packages/cascader/demos/h5/demo5.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ const Demo5 = () => {
66
const [value5, setValue5] = useState(['广东省', '广州市'])
77
const [optionsDemo5] = useState([
88
{ value: '北京', text: '北京', id: 1, pidd: null },
9-
{ value: '朝阳区', text: '朝阳区', id: 11, pidd: 1 },
10-
{ value: '亦庄', text: '亦庄', id: 111, pidd: 11 },
9+
{ value: '通州区', text: '通州区', id: 11, pidd: 1 },
10+
{ value: '经海路', text: '经海路', id: 111, pidd: 11 },
1111
{ value: '广东省', text: '广东省', id: 2, pidd: null },
1212
{ value: '广州市', text: '广州市', id: 21, pidd: 2 },
1313
])

0 commit comments

Comments
 (0)