File tree 2 files changed +10
-2
lines changed
packages/vue-collapsed/src
2 files changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -137,6 +137,8 @@ onMounted(() => {
137
137
// Collapse / Expand handler
138
138
139
139
watch (isExpanded , (isExpanding ) => {
140
+ if (! collapseRef .value ) return
141
+
140
142
if (isExpanding ) {
141
143
if (isReducedOrDisabled (collapseRef )) return onExpanded ()
142
144
@@ -161,7 +163,11 @@ watch(isExpanded, (isExpanding) => {
161
163
})
162
164
163
165
requestAnimationFrame (() => {
166
+ /** If for any unknown edge case the scrollHeight === 0, abort transition force expand */
167
+ if (collapseRef .value ! .scrollHeight === 0 ) return onExpanded ()
168
+
164
169
/** Set height to scrollHeight and trigger the transition. */
170
+
165
171
addStyles ({
166
172
... getHeightProp (collapseRef ),
167
173
... getTransitionProp (collapseRef ),
@@ -186,6 +192,9 @@ watch(isExpanded, (isExpanding) => {
186
192
... getHeightProp (collapseRef ),
187
193
})
188
194
195
+ /** Same as for expand, abort transition and force collapse */
196
+ if (collapseRef .value .scrollHeight === 0 ) return onCollapsed ()
197
+
189
198
requestAnimationFrame (() => {
190
199
/** Set height to baseHeight and trigger the transition. */
191
200
addStyles ({
Original file line number Diff line number Diff line change @@ -43,8 +43,7 @@ export function isReducedOrDisabled(el: RefEl) {
43
43
typeof window . requestAnimationFrame === 'undefined' ||
44
44
window . matchMedia ( '(prefers-reduced-motion: reduce)' ) . matches ||
45
45
transition . includes ( 'none' ) ||
46
- transition . includes ( 'height 0s' ) ||
47
- el . value . scrollHeight === 0
46
+ transition . includes ( 'height 0s' )
48
47
)
49
48
}
50
49
You can’t perform that action at this time.
0 commit comments