fix: check inputRef is HTMLTextAreaElement before getBoundingClientRect
parent
2d4c57a78b
commit
26d2c930b5
|
|
@ -76,11 +76,11 @@ export default function ChatInput(props: {
|
|||
setMentionQuery(query);
|
||||
// 计算位置 - 使用 inputRef 获取最新 DOM 位置
|
||||
requestAnimationFrame(() => {
|
||||
const textarea = inputRef.current;
|
||||
if (!textarea) {
|
||||
console.log('[@mention] inputRef.current is null');
|
||||
if (!(inputRef.current instanceof HTMLTextAreaElement)) {
|
||||
console.log('[@mention] inputRef.current is not textarea:', inputRef.current);
|
||||
return;
|
||||
}
|
||||
const textarea = inputRef.current;
|
||||
const rect = textarea.getBoundingClientRect();
|
||||
console.log('[@mention] textarea rect:', rect);
|
||||
setMentionPos({ top: rect.bottom, left: rect.left + 10 });
|
||||
|
|
|
|||
Loading…
Reference in New Issue