{"record":{"id":"508c208a8c14528e","repo":"unoplatform/uno","slug":"no-pending-drag-and-drop-data","errorCode":null,"errorMessage":"No pending drag and drop data.","messagePattern":"No pending drag and drop data\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/Uno.UI/ts/Windows/ApplicationModel/DataTransfer/DragAndDropExtension.ts","lineNumber":156,"sourceCode":"\n\t\t\t\tevt.dataTransfer.dropEffect = ((args.acceptedOperation) as any);\n\t\t\t} finally {\n\t\t\t\t// No matter if the managed code handled the event, we want to prevent thee default behavior (like opening a drop link)\n\t\t\t\tevt.preventDefault();\n\n\t\t\t\tif (evt.type == \"dragleave\" || evt.type == \"drop\") {\n\t\t\t\t\tthis._pendingDropData = null;\n\t\t\t\t\tthis._pendingDropId = 0;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tpublic static async retrieveText(itemId: number): Promise<string> {\n\n\t\t\tconst current = DragDropExtension._current;\n\t\t\tconst data = current?._pendingDropData;\n\t\t\tif (data == null) {\n\t\t\t\tthrow new Error(\"No pending drag and drop data.\");\n\t\t\t}\n\n\t\t\treturn new Promise((resolve, reject) => {\n\t\t\t\tconst item = data.items[itemId];\n\t\t\t\tconst timeout = setTimeout(() => reject(\"Timeout: for security reason, you cannot access data before drop.\"), 15000);\n\n\t\t\t\titem.getAsString(str => {\n\t\t\t\t\tclearTimeout(timeout);\n\t\t\t\t\tresolve(str);\n\t\t\t\t});\n\t\t\t});\n\t\t}\n\n\t\tpublic static async retrieveFiles(itemIds: number[]): Promise<string> {\n\n\t\t\tconst data = DragDropExtension._current?._pendingDropData;\n\t\t\tif (data == null) {\n\t\t\t\tthrow new Error(\"No pending drag and drop data.\");","sourceCodeStart":138,"sourceCodeEnd":174,"githubUrl":"https://github.com/unoplatform/uno/blob/04183404888ea21b4e5bfa3493e8d5f15e972c3a/src/Uno.UI/ts/Windows/ApplicationModel/DataTransfer/DragAndDropExtension.ts#L138-L174","documentation":"Thrown by DragDropExtension.retrieveText when _pendingDropData on the current DragDropExtension instance is null. _pendingDropData (the DataTransfer object) is set during dragenter and cleared to null on dragleave or drop completion. This means retrieveText was called outside the active drag-drop window.","triggerScenarios":"C# calls retrieveText(itemId) when there is no active drag (no _current instance or _current._pendingDropData is null), or after the drop has already completed (the finally block at line 144-147 clears _pendingDropData on dragleave/drop).","commonSituations":"Calling retrieveText after the drop event has been processed and the DataTransfer was nulled; calling it before any dragenter has set the data; a timing gap where the managed retrieve call arrives after the DOM cleared the pending data.","solutions":["Only call retrieveText while the drag-drop operation is still pending (between dragenter and drop/dragleave).","In the managed drop handler, retrieve text content synchronously within the drop event callback before the TS side clears _pendingDropData.","Guard the managed call with a check that the drag-drop extension is active and has pending data."],"exampleFix":"// before: retrieveText called after drop completed\n// (DataTransfer already nulled in finally block)\nDragDropExtension.retrieveText(itemId); // throws\n\n// after: retrieve inside the drop event before clearing\n// Managed OnDrop handler should call retrieveText\n// before the event finishes processing.","handlingStrategy":"validation","validationCode":"// Before retrieveText, check pending data is still available\nconst current = (<any>DragDropExtension)._current;\nif (current?._pendingDropData == null) {\n    // no active drag — do not retrieve\n    return null;\n}","typeGuard":null,"tryCatchPattern":"try {\n    const text = await DragDropExtension.retrieveText(itemId);\n} catch (e) {\n    if (e.message === 'No pending drag and drop data.') {\n        // drop already completed — nothing to retrieve\n    } else { throw e; }\n}","preventionTips":["Retrieve text synchronously within the managed drop handler before the DOM clears DataTransfer.","Do not defer retrieval to a later async cycle after drop.","Guard managed calls with a check that the drag operation is still pending."],"tags":["wasm","drag-and-drop","data-transfer","lifecycle","typescript"],"backgroundTag":null,"analyzedSha":"04183404888ea21b4e5bfa3493e8d5f15e972c3a","analyzedAt":"2026-08-13T21:08:11.651Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}