소스 검색

fix: 修复AI大纲输入框无法拉高的问题

findChatContainer不再依赖overflow-hidden类名识别flex列容器,
改为通过DOM结构特征(受限高度/overflowY裁剪)向上查找,
兼容大纲面板(无overflow-hidden)和普通聊天面板两种布局结构。
Mochocyang 2 달 전
부모
커밋
2e09eb6a58
1개의 변경된 파일15개의 추가작업 그리고 4개의 파일을 삭제
  1. 15 4
      src/components/chat/chat-input-resize.ts

+ 15 - 4
src/components/chat/chat-input-resize.ts

@@ -43,14 +43,25 @@ export function createResizeContext(rootEl: HTMLDivElement | null, currentInputH
 
 
 function findChatContainer(root: HTMLDivElement): HTMLElement | null {
 function findChatContainer(root: HTMLDivElement): HTMLElement | null {
   let current: HTMLElement | null = root.parentElement
   let current: HTMLElement | null = root.parentElement
-  for (let i = 0; i < 6 && current; i++) {
+  let fallback: HTMLElement | null = null
+  for (let i = 0; i < 8 && current; i++) {
+    const tag = current.tagName
+    if (tag === "BODY" || tag === "HTML") break
     const style = window.getComputedStyle(current)
     const style = window.getComputedStyle(current)
-    if (style.display === "flex" && style.flexDirection === "column" && current.classList.contains("overflow-hidden")) {
-      return current
+    const isFlexColumn = style.display === "flex" && style.flexDirection === "column"
+    if (isFlexColumn) {
+      const hasConstrainedHeight = style.height !== "auto" && style.height !== ""
+      const hasOverflowClip = style.overflowY === "hidden" || style.overflowY === "auto" || style.overflowY === "scroll"
+      if (hasConstrainedHeight || hasOverflowClip) {
+        return current
+      }
+      if (!fallback) {
+        fallback = current
+      }
     }
     }
     current = current.parentElement
     current = current.parentElement
   }
   }
-  return root.parentElement
+  return fallback ?? root.parentElement
 }
 }
 
 
 export function resolveMaxHeightFromContext(ctx: ResizeContext, nextHeight: number): number {
 export function resolveMaxHeightFromContext(ctx: ResizeContext, nextHeight: number): number {