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