fix(chat): restore collapse max height in block mode
This commit is contained in:
parent
3c1773dc01
commit
e3e2d22dc4
@ -959,10 +959,11 @@ const registerCollapseContent = (key: string, el: Element | null) => {
|
||||
if (!(el instanceof HTMLElement)) {
|
||||
return;
|
||||
}
|
||||
const COLLAPSE_MAX_HEIGHT = 600;
|
||||
requestAnimationFrame(() => {
|
||||
const h = el.scrollHeight || el.offsetHeight || 0;
|
||||
if (h > 0) {
|
||||
el.style.setProperty('--collapse-max', `${h}px`);
|
||||
el.style.setProperty('--collapse-max', `${Math.min(h, COLLAPSE_MAX_HEIGHT)}px`);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
@ -211,6 +211,7 @@ const viewportHeight = ref(0);
|
||||
const contentHeights = ref<Record<string, number>>({});
|
||||
const ANIMATION_SYNC_MS = 360;
|
||||
const MORE_ANIMATION_MS = 300;
|
||||
const COLLAPSE_MAX_HEIGHT = 600;
|
||||
let syncRaf: number | null = null;
|
||||
let syncUntil = 0;
|
||||
const isMoreAnimating = ref(false);
|
||||
@ -293,7 +294,9 @@ const setShellMetrics = () => {
|
||||
const action = stackableActions.value[idx];
|
||||
const key = blockKey(action, idx);
|
||||
const content = el.querySelector('.collapsible-content') as HTMLElement | null;
|
||||
const contentHeight = content ? Math.ceil(content.scrollHeight) : 0;
|
||||
const contentHeight = content
|
||||
? Math.min(Math.ceil(content.scrollHeight), COLLAPSE_MAX_HEIGHT)
|
||||
: 0;
|
||||
nextContentHeights[key] = contentHeight;
|
||||
|
||||
// 使用当前真实高度而非「展开/折叠」状态推导值,避免在折叠动画过程中出现高度骤减导致的闪烁
|
||||
|
||||
Loading…
Reference in New Issue
Block a user