feat(prompt-field): add drag-and-drop file upload - #6614
Conversation
Prompt field can now accept a dragged file anywhere over the composer, not just through the + button's picker flow. Dragging over the field reuses the textarea's own focus-ring look rather than introducing a separate drop-target treatment, and dropping fires swc-prompt-field-drop with the raw files so consumers slot artifacts the same way they already do for the picker path. The drag/dragover/dragleave/drop choreography (debounced leave, single-fire entry, cancelable accept) used to live only inside DropzoneBase. Pulled it out into a standalone DragAndDropController so prompt-field could reuse the same battle-tested timing without inheriting Dropzone's own size/filled/dropEffect API. DropzoneBase now delegates to it internally; its public behavior is unchanged. Wired the new event into the pattern's full end-to-end example too.
|
📚 Branch Preview Links🔍 Gen1 Visual Regression Test ResultsWhen a visual regression test fails (or has previously failed while working on this branch), its results can be found in the following URLs:
Deployed to Azure Blob Storage: If the changes are expected, update the |
…cleanup Replaces the three paired addEventListener/removeEventListener calls with a single AbortController aborted on hostDisconnected.
…operty The mode enum was replaced by a plain disabled boolean upstream (#6585), but the drag-and-drop controller and its test still referenced the removed mode/_isDisabled, so disabled fields never actually rejected a drag.
# Conflicts: # 2nd-gen/packages/swc/patterns/conversational-ai/prompt-field/PromptField.ts # 2nd-gen/packages/swc/patterns/conversational-ai/prompt-field/prompt-field.css
…tensity Dragging a file over the field now forces the same ring/background values variant="prominent" + hover uses, regardless of the field's own variant, instead of scaling with whatever variant is currently active. A drop target should read as unmistakable even on a subtle field. Reuses the existing multi-stop radial-gradient background system rather than introducing a flat fill, so the drag wash still looks like a blended gradient rather than the more uniform flat pink in the Figma reference -- a deliberate first pass to compare against a solid-fill version.
Description
Prompt field can now accept a dragged file anywhere over the composer, not just through the
+button's picker flow. Dragging over the field reuses the textarea's own focus-ring look rather than introducing a separate drop-target treatment, and dropping firesswc-prompt-field-dropwith the raw files so consumesize/filled/dropEffect API.DropzoneBasenow delegates to it internally; its public behavior is unchanged.Wired the new event into the pattern's full end-to-end example too.
Motivation and context
The
+button's external picker flow was the only way to attach a file toswc-prompt-field, which is a heavier interaction than the drag-and-drop most conversational AI composers support today. This adds that path without duplicating the drag timing logic Dropzone already had battle-tested, by extracting it into a shared controller.Related issue(s)
Screenshots (if appropriate)
Author's checklist
Reviewer's checklist
patch,minor, ormajorfeaturesManual review test cases
Drag a file over the prompt field shows the focus-ring drop affordance
:focus-visible, with no separate drop-target stylingDropping a file fires
swc-prompt-field-dropand slots an artifactswc-prompt-field-drop delivered 1 file...and slot a media upload artifact, the same as using the+button's external pickerDisabled field rejects the drag
mode="disabled"Dropzone's own behavior is unchanged after the controller extraction
swc-dropzone-should-accept,swc-dropzone-dragover,swc-dropzone-dragleave, andswc-dropzone-dropto fire exactly as before, with the same 100ms dragleave debounceFull pattern example wires the new event
+buttonDevice review
Accessibility testing checklist
Keyboard (required — document steps below)
+button's operability to be unaffected; drag-and-drop is a progressive enhancement only, the+button remains the fully keyboard-operable path for attaching files since native HTML drag-and-drop has no keyboard equivalentScreen reader (required — document steps below)
+button's picker flow