Skip to content

Commit

Permalink
docs(collapse-panel): 在已经打开的面板时修改了内容导致高度改变了面板显示不完整 (#1570)
Browse files Browse the repository at this point in the history
Co-authored-by: hxh <1047739781>
  • Loading branch information
huxinhai committed Sep 10, 2024
1 parent 0aa1bc5 commit 1af6e21
Showing 1 changed file with 23 additions and 4 deletions.
27 changes: 23 additions & 4 deletions src/collapse/collapse-panel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,16 @@ export default defineComponent({
wrapperHeight.value = `${headHeight}px`;
return;
}
const { height: bodyHeight } = bodyRef.value.getBoundingClientRect();
const height = headHeight + bodyHeight;
wrapperHeight.value = `${height}px`;
setContentWrapperHeight();
});
};

watch(
isActive,
() => {
if (wrapperHeight.value === 'auto') {
setContentWrapperHeight();
}
nextTick(() => updatePanelState());
},
{
Expand Down Expand Up @@ -108,13 +109,31 @@ export default defineComponent({
);
};

const setContentWrapperHeight = () => {
const { height: headHeight } = headRef.value.getBoundingClientRect();
const { height: bodyHeight } = bodyRef.value.getBoundingClientRect();
const height = headHeight + bodyHeight;
wrapperHeight.value = `${height}px`;
};

const onTransitionEnd = () => {
if (isActive.value) {
wrapperHeight.value = 'auto';
}
};

return () => {
const headerContent = renderTNodeJSX('header');
const noteContent = renderTNodeJSX('headerRightContent');
const leftIcon = renderTNodeJSX('headerLeftIcon');

return (
<div ref={wrapRef} class={rootClass.value} style={{ height: wrapperHeight.value }}>
<div
ref={wrapRef}
class={rootClass.value}
style={{ height: wrapperHeight.value }}
onTransitionend={onTransitionEnd}
>
<div ref={headRef} class={`${componentName.value}__title`} onClick={handleClick}>
<TCell
class={[
Expand Down

0 comments on commit 1af6e21

Please sign in to comment.