Skip to content

Commit f70d99d

Browse files
Fix text selection issues
1 parent fc85947 commit f70d99d

2 files changed

Lines changed: 33 additions & 3 deletions

File tree

src/player/modules/InteractionController/module.js

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,29 @@
1616

1717
FrameTrail.defineModule('InteractionController', function(FrameTrail){
1818

19-
// Prevent accidental drag-selection of text (one-time global setup).
19+
// Prevent accidental drag-selection of text within FrameTrail's own UI.
2020
// Uses pointer events to cover both mouse and touch input.
2121
// Double/triple-click word/line selection is still allowed via e.detail >= 2.
22+
//
23+
// Scope notes (important — this used to be a document-wide block):
24+
// - The block only applies inside this FrameTrail instance's root element,
25+
// so text on the surrounding host page (when FrameTrail is embedded) stays
26+
// selectable.
27+
// - Selectable content regions are exempted: the interactive transcript,
28+
// form fields, contenteditable areas, and anything opting in via the
29+
// .ft-selectable class. This lets users select transcript text while
30+
// overlay/timeline/slider dragging is still protected.
2231
document.addEventListener('pointerdown', function(e) {
2332
if (e.pointerType !== 'mouse') return; // touch/pen don't trigger selectstart
2433
if (e.detail >= 2) return;
25-
if (e.target.closest('[contenteditable]')) return;
34+
35+
// Only guard within this instance's own UI; never touch host-page selection.
36+
var rootSelector = FrameTrail.getState('target');
37+
if (!rootSelector || !e.target.closest(rootSelector)) return;
38+
39+
// Leave genuinely selectable regions alone.
40+
if (e.target.closest('[contenteditable], input, textarea, .transcriptContainer, .customhtmlContainer, .ft-selectable')) return;
41+
2642
function onSelectStart(evt) {
2743
evt.preventDefault();
2844
}

src/player/types/ContentView/type.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,12 @@ FrameTrail.defineType(
266266

267267
customhtmlContainer.addEventListener('click', function(evt) {
268268
if ( evt.target.classList.contains('timebased') ) {
269+
// Don't seek when the click concludes a text selection,
270+
// so users can select transcript text without the video jumping.
271+
var selection = window.getSelection();
272+
if (selection && !selection.isCollapsed && selection.toString().length > 0) {
273+
return;
274+
}
269275
FrameTrail.module('HypervideoController').currentTime = parseFloat(evt.target.getAttribute('data-start')) + 0.05;
270276
}
271277
});
@@ -308,7 +314,15 @@ FrameTrail.defineType(
308314
}
309315

310316
transcriptContainer.addEventListener('click', function(evt) {
311-
FrameTrail.module('HypervideoController').currentTime = parseFloat(evt.target.getAttribute('data-start')) + 0.05;
317+
// Don't seek when the click concludes a text selection,
318+
// so users can select transcript text without the video jumping.
319+
var selection = window.getSelection();
320+
if (selection && !selection.isCollapsed && selection.toString().length > 0) {
321+
return;
322+
}
323+
var start = evt.target.getAttribute('data-start');
324+
if (start === null) return;
325+
FrameTrail.module('HypervideoController').currentTime = parseFloat(start) + 0.05;
312326
});
313327

314328

0 commit comments

Comments
 (0)