Skip to content

Commit b0e0d47

Browse files
Leah-Xia-Microsoftcarocao-msft
authored andcommitted
[Chat] Fix mention popover position incorrect when insert mention in the middle of long text (#3348)
* Fix Mention Popover's position is too low when insert mention in the middle of a very long text * Change files * Duplicate change files for beta release
1 parent 4634a9a commit b0e0d47

3 files changed

Lines changed: 16 additions & 3 deletions

File tree

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "patch",
3+
"comment": "Fix Mention Popover's position is too low when insert mention in the middle of a very long text",
4+
"packageName": "@azure/communication-react",
5+
"email": "107075081+Leah-Xia-Microsoft@users.noreply.github.com",
6+
"dependentChangeType": "patch"
7+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "patch",
3+
"comment": "Fix Mention Popover's position is too low when insert mention in the middle of a very long text",
4+
"packageName": "@azure/communication-react",
5+
"email": "107075081+Leah-Xia-Microsoft@users.noreply.github.com",
6+
"dependentChangeType": "patch"
7+
}

packages/react-components/src/components/TextFieldWithMention/TextFieldWithMention.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -562,9 +562,8 @@ export const TextFieldWithMention = (props: TextFieldWithMentionProps): JSX.Elem
562562
// Update the caret position, used for positioning the suggestions popover
563563
const textField = event.currentTarget;
564564
const relativePosition = Caret.getRelativePosition(textField);
565-
const adjustOffset = Math.max(0, textField.scrollHeight - textField.clientHeight);
566-
if (relativePosition.top > adjustOffset) {
567-
relativePosition.top -= adjustOffset;
565+
if (textField.scrollHeight > textField.clientHeight) {
566+
relativePosition.top -= textField.scrollTop;
568567
}
569568
setCaretPosition(relativePosition);
570569
if (triggerPriorIndex !== undefined) {

0 commit comments

Comments
 (0)