File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -60,15 +60,19 @@ export default createComponent({
6060 this . inited = true ;
6161 }
6262
63- raf ( ( ) => {
63+ // Use raf: flick when opened in safari
64+ // Use nextTick: closing animation failed when set `user-select: none`
65+ const nextTick = expanded ? this . $nextTick : raf ;
66+
67+ nextTick ( ( ) => {
6468 const { content, wrapper } = this . $refs ;
6569 if ( ! content || ! wrapper ) {
6670 return ;
6771 }
6872
69- const { clientHeight } = content ;
70- if ( clientHeight ) {
71- const contentHeight = `${ clientHeight } px` ;
73+ const { offsetHeight } = content ;
74+ if ( offsetHeight ) {
75+ const contentHeight = `${ offsetHeight } px` ;
7276 wrapper . style . height = expanded ? 0 : contentHeight ;
7377 raf ( ( ) => {
7478 wrapper . style . height = expanded ? contentHeight : 0 ;
@@ -96,7 +100,7 @@ export default createComponent({
96100 if ( ! this . expanded ) {
97101 this . show = false ;
98102 } else {
99- this . $refs . wrapper . style . height = null ;
103+ this . $refs . wrapper . style . height = '' ;
100104 }
101105 }
102106 } ,
Original file line number Diff line number Diff line change @@ -127,8 +127,6 @@ test('lazy render collapse content', async () => {
127127 const titles = wrapper . findAll ( '.van-collapse-item__title' ) ;
128128
129129 titles . at ( 1 ) . trigger ( 'click' ) ;
130- await later ( 50 ) ;
131-
132130 wrapper . vm . content = 'content' ;
133131 expect ( wrapper ) . toMatchSnapshot ( ) ;
134132} ) ;
You can’t perform that action at this time.
0 commit comments