Skip to content

Commit adc67ac

Browse files
committed
Merge branch '4.x' into 5.x
* 4.x: Preserve text selection when clicking datagrid rows
2 parents 7f4c205 + a34750d commit adc67ac

5 files changed

Lines changed: 24 additions & 4 deletions

File tree

assets/js/app.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -532,13 +532,33 @@ class App {
532532
}
533533
};
534534

535+
// when the single-click trigger is active, a drag-to-select gesture ends with a `click`
536+
// event at the release point. Skip navigation in that case so users can highlight and
537+
// copy text from a cell without being navigated away.
538+
const userIsSelectingTextInRow = (row) => {
539+
if ('double' === clickTrigger) {
540+
return false;
541+
}
542+
543+
const selection = window.getSelection();
544+
if (null === selection || 0 === selection.toString().length || 0 === selection.rangeCount) {
545+
return false;
546+
}
547+
548+
return row.contains(selection.getRangeAt(0).commonAncestorContainer);
549+
};
550+
535551
clickableRows.forEach((row) => {
536552
// handle mouse clicks
537553
row.addEventListener(clickTrigger === 'double' ? 'dblclick' : 'click', (event) => {
538554
if (isInteractiveElement(event.target)) {
539555
return;
540556
}
541557

558+
if (userIsSelectingTextInRow(row)) {
559+
return;
560+
}
561+
542562
handleRowActivation(row, event);
543563
});
544564

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

public/entrypoints.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"/app.ef57b823.css"
66
],
77
"js": [
8-
"/app.e8e4fe24.js"
8+
"/app.5145b767.js"
99
]
1010
},
1111
"form": {

public/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"app.css": "app.ef57b823.css",
3-
"app.js": "app.e8e4fe24.js",
3+
"app.js": "app.5145b767.js",
44
"form.js": "form.4f66b3e8.js",
55
"page-layout.js": "page-layout.6e9fe55d.js",
66
"page-color-scheme.js": "page-color-scheme.e3fe1a0a.js",

0 commit comments

Comments
 (0)