SShortSingh.
Back to feed

Why Browser Drag-and-Drop Silently Fails and How to Fix It

0
·29 views

A common but non-obvious bug in HTML drag-and-drop causes dropped elements to snap back with no console error, leaving developers puzzled. The root cause is that browsers block drops on all elements by default, and the only way to unlock a valid drop target is to call e.preventDefault() inside a dragover event listener. Without this single line, the drop event never fires regardless of how correctly the rest of the code is written. A secondary issue involves flickering highlight states on drop zones that contain child elements, caused by dragenter and dragleave events firing at every DOM boundary crossing. This can be resolved by checking the leave event's relatedTarget to confirm the cursor has actually exited the drop zone entirely.

Read the full story at DEV Community

This is an AI-generated summary. ShortSingh links to the original source for the complete article.

Discussion (0)

Log in to join the discussion and vote.

Log in

Related stories

0
ProgrammingDEV Community ·

Excel Freelancer Dashboard Tracks Income, Expenses and Hours in One View

Freelancers often scatter invoices, expenses, hours and bank balances across separate files, making it hard to judge whether they can take on new work. The article proposes a single-page Excel dashboard that can be updated in about 15 minutes a week. It recommends showing four key figures at the top: monthly income, expenses, billable hours and unpaid invoice total. All other figures are drawn from one master table of jobs, so a single status change updates the whole sheet. A month-by-month summary and a list of outstanding invoices round out the layout.

0
ProgrammingDEV Community ·

myOS Portfolio Platform Adds Reddit Posting and Unified Logo in v2.37 to v2.40

The myOS Portfolio Platform has released updates from version 2.37.0 through 2.40.0 as documented in a developer log. The latest version introduces Reddit posting via the free API using a user's own account. Social posting now runs only automatically, with networks connected through a picker, and Bluesky sign-in receives its own card. Secret fields are also now protected from browser autofill. Earlier releases in the series added a unified logo and admin style, README research with an approval step, a phone tab bar, and an AI provider setup guide with cost forecasting.

0
ProgrammingDEV Community ·

Validating URL Search Params in TanStack Start With Zod

Treating URL query parameters as trusted data causes pages to crash, show empty results, or send bad values to the API. TanStack Start addresses this by letting each route declare a validateSearch function that the router runs whenever the URL changes. Using a Zod schema with .catch() instead of .default() replaces invalid values such as a non-numeric page with safe defaults rather than raising errors. Components then read strongly typed search values through Route.useSearch(), without manual parsing or casting. Filters stored in the URL also survive page refreshes, can be shared as links, and respond to the back button.

0
ProgrammingDEV Community ·

Notifio's 38-page product site loads a single 550-byte image and has no screenshots

The developer of Notifio, a desktop app, found that its marketing website contains no screenshots despite the usual convention for selling such software. A count across 38 pages showed the only image loaded on each is a 550-byte SVG bell icon in the header, which the browser caches after the first visit. Instead of screenshots, the site uses inline SVG icons and animated product demos built from HTML elements, which avoids separate image assets and their associated loading and high-density display costs. The developer notes the demos carry trade-offs, including about 997 lines of hand-rolled timer code and an accessibility gap that was addressed. The 214 KB og-image.png used for social previews is never downloaded by ordinary visitors, but is fetched by platforms such as Slack and WhatsApp when links are shared.