unoplatform/uno · error · Error
No pending drag and drop data.
Error message
No pending drag and drop data.
What it means
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.
Source
Thrown at src/Uno.UI/ts/Windows/ApplicationModel/DataTransfer/DragAndDropExtension.ts:156
evt.dataTransfer.dropEffect = ((args.acceptedOperation) as any);
} finally {
// No matter if the managed code handled the event, we want to prevent thee default behavior (like opening a drop link)
evt.preventDefault();
if (evt.type == "dragleave" || evt.type == "drop") {
this._pendingDropData = null;
this._pendingDropId = 0;
}
}
}
public static async retrieveText(itemId: number): Promise<string> {
const current = DragDropExtension._current;
const data = current?._pendingDropData;
if (data == null) {
throw new Error("No pending drag and drop data.");
}
return new Promise((resolve, reject) => {
const item = data.items[itemId];
const timeout = setTimeout(() => reject("Timeout: for security reason, you cannot access data before drop."), 15000);
item.getAsString(str => {
clearTimeout(timeout);
resolve(str);
});
});
}
public static async retrieveFiles(itemIds: number[]): Promise<string> {
const data = DragDropExtension._current?._pendingDropData;
if (data == null) {
throw new Error("No pending drag and drop data.");View on GitHub (pinned to 0418340488)
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.
Example fix
// before: retrieveText called after drop completed // (DataTransfer already nulled in finally block) DragDropExtension.retrieveText(itemId); // throws // after: retrieve inside the drop event before clearing // Managed OnDrop handler should call retrieveText // before the event finishes processing.
Defensive patterns
Strategy: validation
Validate before calling
// Before retrieveText, check pending data is still available
const current = (<any>DragDropExtension)._current;
if (current?._pendingDropData == null) {
// no active drag — do not retrieve
return null;
} Try / catch
try {
const text = await DragDropExtension.retrieveText(itemId);
} catch (e) {
if (e.message === 'No pending drag and drop data.') {
// drop already completed — nothing to retrieve
} else { throw e; }
} Prevention
- 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.
When it happens
Trigger: 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).
Common situations: 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.
Related errors
- A DragDropExtension has already been enabled
- The current DragDropExtension does not match the provided ar
- retrieveFiles failed to find pending drag and drop data for
- Item ${guid} is a directory handle. You cannot use it as a F
- The staged content was released when the download was trigge
AI-assisted analysis of unoplatform/uno@0418340488 (2026-08-13).
Data as JSON: /api/errors/508c208a8c14528e.
Report an issue: GitHub.