@@ -51,7 +51,7 @@ function getTargetPositionLeft(
5151 fullWidthCaret : boolean ,
5252 isLanguageRightToLeft : boolean ,
5353 activeWordElement : HTMLElement ,
54- underscoreAdded : boolean ,
54+ activeWordEmpty : boolean ,
5555 currentWordNodeList : NodeListOf < Element > ,
5656 fullWidthCaretWidth : number ,
5757 wordLen : number ,
@@ -101,7 +101,7 @@ function getTargetPositionLeft(
101101 }
102102 }
103103 result = activeWordElement . offsetLeft + positionOffsetToWord ;
104- if ( underscoreAdded && isLanguageRightToLeft )
104+ if ( activeWordEmpty && isLanguageRightToLeft )
105105 result += activeWordElement . offsetWidth ;
106106 } else {
107107 const wordsWrapperWidth =
@@ -140,13 +140,10 @@ export async function updatePosition(noAnim = false): Promise<void> {
140140 const inputLen = splitIntoCharacters ( TestInput . input . current ) . length ;
141141 if ( Config . mode === "zen" ) wordLen = inputLen ;
142142 const activeWordEl = document ?. querySelector ( "#words .active" ) as HTMLElement ;
143- //insert temporary character so the caret will work in zen mode
144- const activeWordEmpty = activeWordEl ?. children . length === 0 ;
145- if ( activeWordEmpty ) {
146- activeWordEl . insertAdjacentHTML (
147- "beforeend" ,
148- '<letter style="opacity: 0;">_</letter>'
149- ) ;
143+ let activeWordEmpty = false ;
144+ if ( Config . mode === "zen" ) {
145+ wordLen = inputLen ;
146+ if ( inputLen === 0 ) activeWordEmpty = true ;
150147 }
151148
152149 const currentWordNodeList = activeWordEl ?. querySelectorAll ( "letter" ) ;
@@ -254,9 +251,6 @@ export async function updatePosition(noAnim = false): Promise<void> {
254251 } ) ;
255252 }
256253 }
257- if ( activeWordEmpty ) {
258- activeWordEl ?. replaceChildren ( ) ;
259- }
260254}
261255
262256export function show ( noAnim = false ) : void {
0 commit comments