Skip to content

Commit 2fc1a55

Browse files
committed
feat(collapse): 适配鸿蒙
1 parent 91fdf37 commit 2fc1a55

File tree

3 files changed

+10
-21
lines changed

3 files changed

+10
-21
lines changed

src/packages/collapseitem/collapseitem.taro.tsx

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -59,15 +59,13 @@ export const CollapseItem: FunctionComponent<
5959
const contentRef: any = useRef(null)
6060
const uid = useUuid()
6161
const target = `nut-collapse-content-${uid}`
62-
console.log('oasistarget', target)
6362

6463
const expanded = useMemo(() => {
6564
if (context) {
6665
return context.isOpen(name)
6766
}
6867
return false
6968
}, [name, context.isOpen])
70-
console.log('oasis', expanded, name)
7169

7270
const iconStyle = useMemo(() => {
7371
return expanded
@@ -80,21 +78,17 @@ export const CollapseItem: FunctionComponent<
8078
const [wrapperHeight, setWrapperHeight] = useState(0)
8179

8280
const updateRectHeight = async () => {
83-
nextTick(async () => {
84-
const res = await getRectByTaro(contentRef.current, target)
85-
console.log('oasis res', res.height)
86-
if (res?.height) {
87-
setCurrentHeight(res.height)
88-
setWrapperHeight(expanded ? res.height : 0)
89-
setTimeout(() => {
90-
setTran(1)
91-
})
92-
}
93-
})
81+
const res = await getRectByTaro(contentRef.current, target)
82+
if (res?.height) {
83+
setCurrentHeight(res.height)
84+
setWrapperHeight(expanded ? res.height : 0)
85+
nextTick(() => {
86+
setTran(1)
87+
})
88+
}
9489
}
9590
useEffect(() => {
9691
nextTick(() => {
97-
console.log('oasis update', name)
9892
updateRectHeight()
9993
})
10094
}, [children, expanded])
@@ -105,11 +99,10 @@ export const CollapseItem: FunctionComponent<
10599
}
106100
const handleClick = () => {
107101
if (!disabled) {
108-
console.log('oasis name', name)
109102
context.updateValue(name)
110-
nextTick(() => {
103+
setTimeout(() => {
111104
toggle()
112-
})
105+
}, 150)
113106
}
114107
}
115108

src/packages/collapseitem/collapseitem.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ export const CollapseItem: FunctionComponent<
6060
}
6161
return false
6262
}, [name, context.isOpen])
63-
console.log('oasis', expanded, name)
6463

6564
const iconStyle = useMemo(() => {
6665
return expanded
@@ -74,7 +73,6 @@ export const CollapseItem: FunctionComponent<
7473

7574
const updateRectHeight = async () => {
7675
const height = contentRef.current.offsetHeight
77-
console.log('oasis res', height)
7876
if (height) {
7977
setCurrentHeight(height)
8078
setWrapperHeight(expanded ? height : 0)
@@ -94,7 +92,6 @@ export const CollapseItem: FunctionComponent<
9492
}
9593
const handleClick = () => {
9694
if (!disabled) {
97-
console.log('oasis name', name)
9895
context.updateValue(name)
9996
toggle()
10097
}

src/utils/get-rect-by-taro.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ export const getRectByTaro = async (
3434
// 小程序下的逻辑
3535
return new Promise((resolve, reject) => {
3636
createSelectorQuery()
37-
.in(element)
3837
.select(`#${harmonyId || element.uid}`)
3938
.boundingClientRect()
4039
.exec(([rects]) => {

0 commit comments

Comments
 (0)