@redseed/redseed-ui-vue3 10.3.1 → 10.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script setup>
|
|
2
|
-
import { ref, watch, watchEffect, nextTick, onMounted, onBeforeUnmount } from 'vue'
|
|
2
|
+
import { ref, shallowRef, watch, watchEffect, nextTick, onMounted, onBeforeUnmount } from 'vue'
|
|
3
3
|
import { ChevronDownIcon } from '@heroicons/vue/24/outline'
|
|
4
4
|
import { ButtonTertiary } from '../Button'
|
|
5
5
|
import Icon from '../Icon/Icon.vue'
|
|
@@ -50,6 +50,8 @@ async function setContentMaxHeight() {
|
|
|
50
50
|
|
|
51
51
|
await nextTick()
|
|
52
52
|
|
|
53
|
+
if (!contentRef.value) return
|
|
54
|
+
|
|
53
55
|
contentRef.value.style.minHeight = contentRef.value.scrollHeight + 'px'
|
|
54
56
|
}
|
|
55
57
|
|
|
@@ -58,6 +60,8 @@ async function resetContentMaxHeight() {
|
|
|
58
60
|
|
|
59
61
|
await nextTick()
|
|
60
62
|
|
|
63
|
+
if (!contentRef.value) return
|
|
64
|
+
|
|
61
65
|
contentRef.value.style.removeProperty('min-height')
|
|
62
66
|
}
|
|
63
67
|
|
|
@@ -88,7 +92,7 @@ watch(isOpen, (open, wasOpen) => {
|
|
|
88
92
|
}, { flush: 'sync' })
|
|
89
93
|
|
|
90
94
|
/**
|
|
91
|
-
*
|
|
95
|
+
* Each teleport target's current element, or null while it is absent.
|
|
92
96
|
*
|
|
93
97
|
* Re-checked rather than latched. These used to only ever flip true, and the
|
|
94
98
|
* observer disconnected once both had been found — so a consumer that removed a
|
|
@@ -96,15 +100,23 @@ watch(isOpen, (open, wasOpen) => {
|
|
|
96
100
|
* `SectionHeader` does exactly that: it width-gates the slots a target is
|
|
97
101
|
* mounted into, so narrowing a header past 640px took the trigger away and the
|
|
98
102
|
* section could no longer be opened. See #372.
|
|
103
|
+
*
|
|
104
|
+
* The element itself goes to `to`, not an `#id` selector. Vue resolves a
|
|
105
|
+
* selector once, when the Teleport mounts, and never again when only
|
|
106
|
+
* `disabled` flips. A Disclosure mounted inside a subtree that is not yet in the
|
|
107
|
+
* document resolved null there, and enabling it then threw "Cannot read
|
|
108
|
+
* properties of null (reading 'insertBefore')" and wedged the whole page. A
|
|
109
|
+
* changed `to` is re-resolved, so a target that appears late or is re-created
|
|
110
|
+
* gets the content moved into the live element.
|
|
99
111
|
*/
|
|
100
|
-
const
|
|
101
|
-
const
|
|
112
|
+
const triggerTarget = shallowRef(null)
|
|
113
|
+
const contentTarget = shallowRef(null)
|
|
102
114
|
|
|
103
115
|
let observer = null
|
|
104
116
|
|
|
105
117
|
function setTeleport() {
|
|
106
|
-
|
|
107
|
-
|
|
118
|
+
triggerTarget.value = document.getElementById(triggerId)
|
|
119
|
+
contentTarget.value = document.getElementById(contentId)
|
|
108
120
|
}
|
|
109
121
|
|
|
110
122
|
onMounted(() => {
|
|
@@ -149,8 +161,8 @@ onBeforeUnmount(() => {
|
|
|
149
161
|
Vue's own `disabled` keeps this as one definition rendered in one of two
|
|
150
162
|
places, rather than two copies that can drift.
|
|
151
163
|
-->
|
|
152
|
-
<Teleport :to="
|
|
153
|
-
:disabled="!
|
|
164
|
+
<Teleport :to="triggerTarget"
|
|
165
|
+
:disabled="!triggerTarget"
|
|
154
166
|
>
|
|
155
167
|
<slot name="trigger"
|
|
156
168
|
:handleTrigger="handleTrigger"
|
|
@@ -184,8 +196,8 @@ onBeforeUnmount(() => {
|
|
|
184
196
|
</Teleport>
|
|
185
197
|
|
|
186
198
|
<!-- Same reasoning as the trigger above: in place rather than nowhere. -->
|
|
187
|
-
<Teleport :to="
|
|
188
|
-
:disabled="!
|
|
199
|
+
<Teleport :to="contentTarget"
|
|
200
|
+
:disabled="!contentTarget"
|
|
189
201
|
>
|
|
190
202
|
<div ref="contentRef"
|
|
191
203
|
:class="[
|