File tree Expand file tree Collapse file tree 2 files changed +10
-1
lines changed
Expand file tree Collapse file tree 2 files changed +10
-1
lines changed Original file line number Diff line number Diff line change 11{
22 "name" : " vue-collapsed" ,
3- "version" : " 1.3.2 " ,
3+ "version" : " 1.3.3 " ,
44 "private" : false ,
55 "description" : " Dynamic CSS height transition from any to auto and vice versa for Vue 3. Accordion ready." ,
66 "keywords" : [
Original file line number Diff line number Diff line change @@ -137,6 +137,8 @@ onMounted(() => {
137137// Collapse / Expand handler
138138
139139watch (isExpanded , (isExpanding ) => {
140+ if (! collapseRef .value ) return
141+
140142 if (isExpanding ) {
141143 if (isReducedOrDisabled (collapseRef )) return onExpanded ()
142144
@@ -161,7 +163,11 @@ watch(isExpanded, (isExpanding) => {
161163 })
162164
163165 requestAnimationFrame (() => {
166+ /** If for any unknown edge case the scrollHeight === 0, abort transition and force expand */
167+ if (collapseRef .value ! .scrollHeight === 0 ) return onExpanded ()
168+
164169 /** Set height to scrollHeight and trigger the transition. */
170+
165171 addStyles ({
166172 ... getHeightProp (collapseRef ),
167173 ... getTransitionProp (collapseRef ),
@@ -186,6 +192,9 @@ watch(isExpanded, (isExpanding) => {
186192 ... getHeightProp (collapseRef ),
187193 })
188194
195+ /** Same as for expand, abort transition and force collapse */
196+ if (collapseRef .value .scrollHeight === 0 ) return onCollapsed ()
197+
189198 requestAnimationFrame (() => {
190199 /** Set height to baseHeight and trigger the transition. */
191200 addStyles ({
You can’t perform that action at this time.
0 commit comments