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:
1 parent
edde67ddd4
commit
5d01b5eb6a
1 file changed
+10
@@ -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;\
|
||||
}}\
|
||||
}}\
|
||||
}}\
|
||||
}}\
|
||||
|
||||
Reference in new issue
Block a user