Skip to content

Commit

Permalink
hopefully fix ResizeObserver loop error
Browse files Browse the repository at this point in the history
  • Loading branch information
joshuaboud committed Dec 3, 2024
1 parent 13eef91 commit d54d783
Showing 1 changed file with 7 additions and 18 deletions.
25 changes: 7 additions & 18 deletions houston-common-ui/lib/components/Disclosure.vue
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
<script setup lang="ts">
import {
defineModel,
onMounted,
ref,
computed,
onUnmounted,
defineProps,
watchEffect,
} from "vue";
import { defineModel, onMounted, ref, computed, onUnmounted, defineProps, watchEffect } from "vue";
import { ChevronUpIcon } from "@heroicons/vue/20/solid";
const props = withDefaults(
Expand All @@ -26,9 +18,7 @@ const props = withDefaults(
const show = defineModel<boolean>("show", { default: false });
const wrapperElement = ref<InstanceType<typeof HTMLDivElement> | null>(null);
const internalWrapperElement = ref<InstanceType<typeof HTMLDivElement> | null>(
null
);
const internalWrapperElement = ref<InstanceType<typeof HTMLDivElement> | null>(null);
const internalHeight = ref(0);
Expand All @@ -38,8 +28,10 @@ const elementHeight = computed<number>(() => {
});
const observer = new ResizeObserver((entries) => {
entries.forEach((entry) => {
internalHeight.value = entry.contentRect.height;
requestAnimationFrame(() => {
for (const entry of entries) {
internalHeight.value = entry.contentRect.height;
}
});
});
Expand Down Expand Up @@ -102,10 +94,7 @@ onUnmounted(() => {
'max-height': `${elementHeight}px`,
'transition-duration': `${transitionDuration}ms`,
}"
:class="[
show ? 'ease-out' : 'ease-in',
`transition-[max-height] overflow-y-hidden w-full`,
]"
:class="[show ? 'ease-out' : 'ease-in', `transition-[max-height] overflow-y-hidden w-full`]"
>
<div ref="internalWrapperElement">
<slot :visible="visible" :show="show" />
Expand Down

0 comments on commit d54d783

Please sign in to comment.