@@ -153,6 +153,7 @@ export default defineComponent({
153
153
const inputInstRef = ref < InputInst | null > ( null )
154
154
const cursorRef = ref < HTMLElement | null > ( null )
155
155
const followerRef = ref < FollowerInst | null > ( null )
156
+ const wrapperElRef = ref < HTMLElement | null > ( null )
156
157
const partialPatternRef = ref < string > ( '' )
157
158
let cachedPrefix : string | null = null
158
159
// cached pattern end is for partial pattern
@@ -277,9 +278,11 @@ export default defineComponent({
277
278
top : number
278
279
height : number
279
280
} = getRelativePosition ( inputEl )
280
- cursorPos . left += inputEl . parentElement ! . offsetLeft
281
- cursorAnchor . style . left = `${ cursorPos . left } px`
282
- cursorAnchor . style . top = `${ cursorPos . top + cursorPos . height } px`
281
+ const inputRect = inputEl . getBoundingClientRect ( )
282
+ const wrapperRect = wrapperElRef . value ! . getBoundingClientRect ( )
283
+ cursorAnchor . style . left = `${ cursorPos . left + inputRect . left - wrapperRect . left } px`
284
+ cursorAnchor . style . top = `${ cursorPos . top + inputRect . top - wrapperRect . top } px`
285
+ cursorAnchor . style . height = `${ cursorPos . height } px`
283
286
}
284
287
function syncPosition ( ) : void {
285
288
if ( ! showMenuRef . value )
@@ -419,6 +422,7 @@ export default defineComponent({
419
422
inputInstRef,
420
423
cursorRef,
421
424
followerRef,
425
+ wrapperElRef,
422
426
showMenu : showMenuRef ,
423
427
adjustedTo : useAdjustedTo ( props ) ,
424
428
isMounted : useIsMounted ( ) ,
@@ -439,7 +443,7 @@ export default defineComponent({
439
443
render ( ) {
440
444
const { mergedTheme, mergedClsPrefix, $slots } = this
441
445
return (
442
- < div class = { `${ mergedClsPrefix } -mention` } >
446
+ < div class = { `${ mergedClsPrefix } -mention` } ref = "wrapperElRef" >
443
447
< NInput
444
448
status = { this . mergedStatus }
445
449
themeOverrides = { mergedTheme . peerOverrides . Input }
@@ -466,12 +470,10 @@ export default defineComponent({
466
470
default : ( ) => {
467
471
const style : CSSProperties = {
468
472
position : 'absolute' ,
469
- width : 0 ,
470
- height : 0
473
+ width : 0
471
474
}
472
475
if ( __DEV__ && this . internalDebug ) {
473
476
style . width = '1px'
474
- style . height = '1px'
475
477
style . background = 'red'
476
478
}
477
479
return < div style = { style } ref = "cursorRef" />
0 commit comments