Phenomenon
When dragging and dropping an image file into a contenteditable element in Chrome, the image may be inserted at an incorrect position. The drop position does not match the cursor position or drop location.
Reproduction example
- Create contenteditable with text
- Place cursor at a specific position
- Drag and drop an image file
Observed behavior
- Image is inserted at wrong position
- Drop position does not match cursor
- Or image is inserted at end of content
- Position is unpredictable
Expected behavior
- Image should be inserted at drop location
- Or at cursor position
- Position should be predictable
- Drop should work intuitively
Browser Comparison
- Chrome/Edge: Position may be incorrect (this case)
- Firefox: Similar position issues
- Safari: Drop position most unpredictable
Notes and possible direction for workarounds
- Intercept drop event
- Calculate drop position from event coordinates
- Insert image at calculated position
- Use
document.caretRangeFromPointif available
