Skip to content

Commit

Permalink
clipboard: hide download dialog when changed selection
Browse files Browse the repository at this point in the history
user changed selection - it means we no longer want to download
content but we do something else

Signed-off-by: Szymon Kłos <[email protected]>
Change-Id: I5df0a63baa1bf1ae85567430d531dd7800ad6cd0
  • Loading branch information
eszkadev committed Oct 6, 2023
1 parent 3ad6360 commit c00a9b5
Showing 1 changed file with 7 additions and 17 deletions.
24 changes: 7 additions & 17 deletions browser/src/map/Clipboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -773,7 +773,7 @@ L.Clipboard = L.Class.extend({
clearSelection: function() {
this._selectionContent = '';
this._selectionType = null;
this._scheduleHideDownload(15);
this._scheduleHideDownload();
},

// textselectioncontent: message
Expand All @@ -783,22 +783,22 @@ L.Clipboard = L.Class.extend({
if (L.Browser.cypressTest) {
this._dummyDiv.innerHTML = html;
}
this._scheduleHideDownload(15);
this._scheduleHideDownload();
},

// sets the selection to some (cell formula) text)
setTextSelectionText: function(text) {
this._selectionType = 'text';
this._selectionContent = this._originWrapBody(
'<body>' + text + '</body>');
this._scheduleHideDownload(15);
this._scheduleHideDownload();
},

// complexselection: message
onComplexSelection: function (/*text*/) {
// Mark this selection as complex.
this._selectionType = 'complex';
this._scheduleHideDownload(15);
this._scheduleHideDownload();
},

_startProgress: function() {
Expand All @@ -825,26 +825,16 @@ L.Clipboard = L.Class.extend({
},

// Download button is still shown after selection changed -> user has changed their mind...
_scheduleHideDownload: function(s) {
_scheduleHideDownload: function() {
if (!this._downloadProgress || this._downloadProgress.isClosed())
return;

// If no other copy/paste things occurred then ...
var that = this;
var serial = this._clipboardSerial;
if (!this._hideDownloadTimer)
this._hideDownloadTimer = setTimeout(function() {
that._hideDownloadTimer = null;
if (serial == that._clipboardSerial && that._downloadProgressStatus() === 'downloadButton')
that._stopHideDownload();
}, 1000 * s);
if (this._downloadProgressStatus() === 'downloadButton')
this._stopHideDownload();
},

// useful if we did an internal paste already and don't want that.
_stopHideDownload: function() {
clearTimeout(this._hideDownloadTimer);
this._hideDownloadTimer = null;

if (!this._downloadProgress || this._downloadProgress.isClosed())
return;
this._downloadProgress._onClose();
Expand Down

0 comments on commit c00a9b5

Please sign in to comment.