From 5d01b5eb6a97bda9b249c12f3b422f90d2b25295 Mon Sep 17 00:00:00 2001 From: zhangyang-crazy-one <740884666@qq.com> Date: Tue, 23 Jun 2026 19:26:18 +0800 Subject: [PATCH] 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. --- crates/obscura-cdp/src/domains/input.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/crates/obscura-cdp/src/domains/input.rs b/crates/obscura-cdp/src/domains/input.rs index 1e0010a..519e2a5 100644 --- a/crates/obscura-cdp/src/domains/input.rs +++ b/crates/obscura-cdp/src/domains/input.rs @@ -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;\ + }}\ }}\ }}\ }}\