You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
selectionchange events to be fired, similar to the native input.
Actual behavior
selectionchange events did not fire.
Additional context
I was working on a headless OTP input, that required the use of selection change events. I noticed the actual behavior in the browser was inconsistent with what I was seeing in the playwright test.
A current workaround is having it take a snapshot of the selectionchange event each time.
asyncfunctionsetupEventListeners(input: Locator){awaitinput.evaluate((el)=>{returnnewPromise<void>((resolve)=>{letlastStart=(elasHTMLInputElement).selectionStart;letlastEnd=(elasHTMLInputElement).selectionEnd;letstableCount=0;letisResolved=false;constcheckSelection=()=>{if(isResolved)return;constcurrentStart=(elasHTMLInputElement).selectionStart;constcurrentEnd=(elasHTMLInputElement).selectionEnd;console.log("selection:",currentStart,currentEnd);if(currentStart===lastStart&¤tEnd===lastEnd){stableCount++;if(stableCount>=3){isResolved=true;resolve();return;}}else{stableCount=0;}lastStart=currentStart;lastEnd=currentEnd;requestAnimationFrame(checkSelection);};constselectionListener=()=>{if(isResolved)return;console.log("selection change:",(elasHTMLInputElement).selectionStart,(elasHTMLInputElement).selectionEnd);stableCount=0;};el.addEventListener("selectionchange",selectionListener);checkSelection();// Cleanup after 5 seconds to prevent hangingsetTimeout(()=>{if(!isResolved){isResolved=true;el.removeEventListener("selectionchange",selectionListener);resolve();}},5000);});});}
Version
1.46.0
Steps to reproduce
Expected behavior
selectionchange events to be fired, similar to the native input.
Actual behavior
selectionchange events did not fire.
Additional context
I was working on a headless OTP input, that required the use of selection change events. I noticed the actual behavior in the browser was inconsistent with what I was seeing in the playwright test.
A current workaround is having it take a snapshot of the selectionchange event each time.
Environment
The text was updated successfully, but these errors were encountered: