Skip to content

Commit

Permalink
feat(cc-logs): select whole log line with triple click
Browse files Browse the repository at this point in the history
Fixes #1006
  • Loading branch information
pdesoyres-cc committed Jun 20, 2024
1 parent 4b0eefc commit 2c9c02b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
18 changes: 16 additions & 2 deletions src/components/cc-logs/cc-logs.js
Original file line number Diff line number Diff line change
Expand Up @@ -567,9 +567,23 @@ export class CcLogs extends LitElement {
* This function is wired through `this._inputCtrl`.
*
* It clears the selection when users click on the logs container but not in the gutter area.
* It also handles triple click: selects the whole log line (including timestamp and metadata)
*
* @param {MouseEvent & {target : HTMLElement}} e
*/
_onClick () {
this._logsCtrl.clearSelection();
_onClick (e) {
if (e.detail === 3) {
const logElement = e.target.closest(`.log`);
if (logElement != null) {
window.getSelection().empty();
const range = document.createRange();
range.selectNode(logElement);
window.getSelection().addRange(range);
}
}
else {
this._logsCtrl.clearSelection();
}
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/components/cc-logs/logs-input-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ export class LogsInputController {
// Firefox doesn't! And we think that a drag movement ending should not be a click.
// Therefore, if a drag stop just happened (_dragState = stopping) we should not trigger the onClick on the host.
if (this._dragState !== 'stopping') {
this._host._onClick();
this._host._onClick(e);
}
}

Expand Down

0 comments on commit 2c9c02b

Please sign in to comment.