mirror of
				https://github.com/Jermolene/TiddlyWiki5
				synced 2025-10-29 14:47:40 +00:00 
			
		
		
		
	Fix: issues with drag and drop in Chrome 96 (#6261)
* fix: issues with drag and drop (false positives in detection for files being dropped) introduced by Chrome 96 * fix: call dragEventContainsType method more consistently. * fix: call dragEventContainsType method more consistently.
This commit is contained in:
		| @@ -324,7 +324,7 @@ function editTextWidgetFactory(toolbarEngine,nonToolbarEngine) { | ||||
| 	If there are no Files, let the browser handle it. | ||||
| 	*/ | ||||
| 	EditTextWidget.prototype.handleDropEvent = function(event) { | ||||
| 		if(event.dataTransfer.files.length) { | ||||
| 		if($tw.utils.dragEventContainsFiles(event)) { | ||||
| 			event.preventDefault(); | ||||
| 			event.stopPropagation(); | ||||
| 			this.dispatchDOMEvent(this.cloneEvent(event,["dataTransfer"])); | ||||
|   | ||||
| @@ -208,10 +208,10 @@ function parseJSONTiddlers(json,fallbackTitle) { | ||||
| 	return data; | ||||
| }; | ||||
|  | ||||
| exports.dragEventContainsFiles = function(event) { | ||||
| function dragEventContainsType(event,targetType) { | ||||
| 	if(event.dataTransfer.types) { | ||||
| 		for(var i=0; i<event.dataTransfer.types.length; i++) { | ||||
| 			if(event.dataTransfer.types[i] === "Files") { | ||||
| 			if(event.dataTransfer.types[i] === targetType) { | ||||
| 				return true; | ||||
| 				break; | ||||
| 			} | ||||
| @@ -220,4 +220,10 @@ exports.dragEventContainsFiles = function(event) { | ||||
| 	return false; | ||||
| }; | ||||
|  | ||||
| exports.dragEventContainsFiles = function(event) { | ||||
| 	return (dragEventContainsType(event,"Files") && !dragEventContainsType(event,"text/plain")); | ||||
| }; | ||||
|  | ||||
| exports.dragEventContainsType = dragEventContainsType; | ||||
|  | ||||
| })(); | ||||
|   | ||||
| @@ -198,7 +198,8 @@ DropZoneWidget.prototype.handleDropEvent  = function(event) { | ||||
| 	this.resetState(); | ||||
| 	// Import any files in the drop | ||||
| 	var numFiles = 0; | ||||
| 	if(dataTransfer.files) { | ||||
| 	// If we have type text/vnd.tiddlywiki then skip trying to import files | ||||
| 	if(dataTransfer.files && !$tw.utils.dragEventContainsType(event,"text/vnd.tiddler")) { | ||||
| 		numFiles = this.wiki.readFiles(dataTransfer.files,{ | ||||
| 			callback: readFileCallback, | ||||
| 			deserializer: this.dropzoneDeserializer | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Saq Imtiaz
					Saq Imtiaz