Skip to content

Commit bb5ca09

Browse files
authored
1.3.3 (#28)
* force onExpanded/onCollapsed for edge cases, fix #25 * bump 1.3.3 * force onExpanded/onCollapsed for edge cases, fix #25, 2 * cleanup
1 parent 8c508d4 commit bb5ca09

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

packages/vue-collapsed/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
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": [

packages/vue-collapsed/src/Collapse.vue

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,8 @@ onMounted(() => {
137137
// Collapse / Expand handler
138138
139139
watch(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({

0 commit comments

Comments
 (0)