Closed EnterpriseDT closed 6 years ago
I think I've got a fix for this. The problem originates in ng-file-upload, which supports pasting of files via the clipboard, i.e. you can copy a file from the OS's file-manager and paste it into ng-file-upload. It's tied in with drag-dropping files, so when I tried to disable the pasting of files, drag-drop was also disabled, which I didn't want.
My fix involves preventing multiple modals showing on top of each other. Hopefully this doesn't break something else.
I implemented this using a new scope variable called isModalShowing
in main.js
:
$scope.isModalShowing = false;
In then added code to the modal
function in main.js such that isModalShowing
is true when a modal is showing and also preventing another modal showing when isModalShowing
is true:
$scope.modal = function(id, hide, returnElement) {
if ($scope.isModalShowing)
return;
var element = angular.element('#' + id);
var scope = $scope;
element.off('hidden.bs.modal').on('hidden.bs.modal', function () {
scope.isModalShowing = false;
});
element.modal(hide ? 'hide' : 'show');
$scope.isModalShowing = !hide;
$scope.apiMiddleware.apiHandler.error = '';
$scope.apiMiddleware.apiHandler.asyncSuccess = false;
return returnElement ? element : true;
};
finally, to prevent clipboard text from being added to the upload-queue I added code in addForUpload
:
$scope.addForUpload = function($files) {
if ($scope.isModalShowing)
return;
$scope.uploadFileList = $scope.uploadFileList.concat($files);
$scope.modal('uploadfile');
};
I think I've got a better fix for this: simply modify addForUpload so that nothing is done unless File objects are passed to the method.
$scope.addForUpload = function($files) {
var files = [];
$files.forEach(function(file) {
if (file instanceof File)
files.push(file);
});
if (files.length == 0)
return;
$scope.uploadFileList = $scope.uploadFileList.concat(files);
$scope.modal('uploadfile');
};
Hi, thank for your report.
This problem is related to the ng-file-upload
extension.
We are working on it. Thanks.
Just fixed in master. I've added the ngf-model-options to disable the paste event that triggers the upload form.
Bug description: Pasting text from the clipboard into the folder-name textbox on new-folder modal results in the upload-files modal being opened.
Environment:
Steps to reproduce:
Expected result: Clipboard text should appear in textbox. Actual result: Interface immediately opens the upload-files modal.