Skip to content
Back to skills

Drag And Drop

ASecurity

Implement drag-and-drop in LWC using HTML5 Drag and Drop API, keyboard alternatives, and accessible announcements. NOT for kanban migration from legacy Lightning.

  • 3 stars
  • 0 votes
  • 0 copies
  • 2 views
  • Added September 8, 2026
designgospringgitapi

Works with

  • api

Security analysis

A100/100

Pro scans all 7 files and shows the line behind each finding

Scanned September 8, 2026

npx -y skills add BanibrataChatterjee/AwesomeSalesforceSkills --skill drag-and-drop --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Drag And Drop?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Drag And Drop
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/banibratachatterjee-drag-and-drop/badge)](https://www.skillsdirectory.com/skills/banibratachatterjee-drag-and-drop)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: drag-and-drop
description: "Implement drag-and-drop in LWC using HTML5 Drag and Drop API, keyboard alternatives, and accessible announcements. NOT for kanban migration from legacy Lightning."
category: lwc
salesforce-version: "Spring '25+"
well-architected-pillars:
  - User Experience
  - Reliability
triggers:
  - "lwc drag drop"
  - "reorder list lwc"
  - "drag file into lwc"
  - "kanban drag and drop lwc"
tags:
  - lwc
  - drag-drop
  - a11y
inputs:
  - "items to reorder or move"
  - "accessibility requirements"
outputs:
  - "component with dragstart/dragover/drop handlers + keyboard fallback"
dependencies: []
version: 1.0.0
author: Pranav Nagrecha
updated: 2026-04-17
---

# LWC Drag and Drop

Native HTML5 Drag and Drop works in LWC — no library needed. The tricky parts are (1) preventing default on dragover, (2) carrying item identity via dataTransfer, and (3) providing a keyboard-accessible alternative (focus + arrow keys). This skill lays out the template, the JS handlers, and the ARIA live-region announcements.

## When to Use

Any reordering UI (priority list, board columns, file drop zones). Not for complex trees (use a specialized library behind an LWC wrapper).

Typical trigger phrases that should route to this skill: `lwc drag drop`, `reorder list lwc`, `drag file into lwc`, `kanban drag and drop lwc`.

## Recommended Workflow

1. Template: add `draggable="true"`, `@dragstart`, `@dragover` (with preventDefault), `@drop` on source/target elements.
2. Pass identity via `event.dataTransfer.setData('text/plain', itemId)`.
3. Keyboard alternative: `@keydown` on item, arrow keys reorder with the same handler logic.
4. Announce drag start/drop via a `role="status"` aria-live region.
5. Jest test: simulate dragstart/drop; assert reorder + announcement.

## Key Considerations

- `dragover` must call `event.preventDefault()` or `drop` never fires.
- Touch devices don't fire drag events — detect and show reorder buttons.
- dataTransfer is cleared after drop — capture any data synchronously in dragstart.
- aria-grabbed is deprecated; announce via live region instead.

## Worked Examples (see `references/examples.md`)

- *Priority list reorder* — Case priority list
- *File drop zone* — Attachments upload

## Common Gotchas (see `references/gotchas.md`)

- **Missing preventDefault** — Drop never fires; silent bug.
- **Touch devices** — Mobile users can't reorder.
- **No keyboard path** — A11y audit fails.

## Top LLM Anti-Patterns (full list in `references/llm-anti-patterns.md`)

- Using an external drag library for simple lists
- Skipping keyboard support
- No aria-live announcement

## Official Sources Used

- Lightning Web Components Developer Guide — https://developer.salesforce.com/docs/platform/lwc/guide/
- Lightning Data Service — https://developer.salesforce.com/docs/platform/lwc/guide/data-wire-service-about.html
- LWC Recipes — https://github.com/trailheadapps/lwc-recipes
- SLDS 2 — https://www.lightningdesignsystem.com/2e/

Files in this skill

  • SKILL.md2.9 KB
  • references/examples.md567 B
  • references/gotchas.md588 B
  • references/llm-anti-patterns.md229 B
  • references/well-architected.md470 B
  • scripts/check_drag_and_drop.py897 B
  • templates/drag-and-drop-template.md532 B

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in design →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.