fix(cdp): implement triple-click select-all for text inputs (#316 follow-up) (#320)

Passing detail:clickCount to MouseEvent is necessary but not sufficient
for triple-click to select all text. The select-all-on-triple-click is a
browser native behavior that synthetic MouseEvent dispatch doesn't trigger.

Add manual selection after click dispatch: when clickCount >= 3 and the
target is an INPUT or TEXTAREA, set selectionStart=0 and
selectionEnd=value.length.
This commit is contained in:
zhangyang-crazy-one authored and GitHub committed 2026-06-23 13:26:18 +02:00
1 parent edde67ddd4
commit 5d01b5eb6a
1 file changed
+10
+10
View File
@@ -47,6 +47,16 @@ pub async fn handle(
}} else if (tag === 'INPUT' && (type === 'checkbox' || type === 'radio')) {{\
target.checked = !target.checked;\
try {{ target.dispatchEvent(globalThis.__obscura_markTrusted(new Event('change', {{bubbles:true}}))); }} catch(e) {{}}\
}} else if ({click_count} >= 3 && (tag === 'INPUT' || tag === 'TEXTAREA')) {{\
// Triple-click selects all text (browser native behavior not replicated
// by synthetic MouseEvent, so we do it manually).
var len = target.value ? target.value.length : 0;\
if (target.setSelectionRange) {{\
target.setSelectionRange(0, len);\
}} else {{\
target.selectionStart = 0;\
target.selectionEnd = len;\
}}\
}}\
}}\
}}\