Skip to content

Commit

Permalink
followup: no copy event is emitted by hitting CTRL+C with no selection
Browse files Browse the repository at this point in the history
This is still occurring also in Firefox 118.
Anyway it seems to never occur on Windows.

Signed-off-by: Marco Cecchetti <[email protected]>
Change-Id: I0e5c643912f2276c60bdba1b2ad1ed801785193f
  • Loading branch information
mcecchetti committed Oct 12, 2023
1 parent dffef0e commit da59a84
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions browser/src/layer/marker/TextInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -954,11 +954,12 @@ L.TextInput = L.Layer.extend({
this._newlineHint = ev.keyCode === 13;
this._linebreakHint = this._newlineHint && ev.shiftKey;

// In Firefox 117 no copy/cut input event is emitted when CTRL+C/X is pressed with no selection
// in a text element with contenteditable='true'. Since no copy/cut event is emitted,
// Clipboard.copy/cut is never invoked. So we need to emit it manually.
// In Firefox 117 and greater no copy/cut input event is emitted when CTRL+C/X is pressed
// with no selection in a text element with contenteditable='true'. Since no copy/cut event
// is emitted, Clipboard.copy/cut is never invoked. So we need to emit it manually.
// To be honest it seems a Firefox bug. We need to check if they fix it in later version.
if (!this.hasAccessibilitySupport() && L.Browser.gecko && L.Browser.geckoVersion === '117.0' &&
if (!this.hasAccessibilitySupport() && !L.Browser.win &&
L.Browser.gecko && L.Browser.geckoVersion >= '117.0' &&
ev.ctrlKey && window.getSelection().isCollapsed) {
if (ev.key === 'c') {
document.execCommand('copy');
Expand Down

0 comments on commit da59a84

Please sign in to comment.