bounds don't work with svg element

Open
#467 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
javascript, react
Domain
frontend

Research direction

Start with the provided Draggable reproduction containing the SVG, grouped rect, and bounds="parent" or bounds="#mostouter". Trace how the Draggable component calculates bounds for SVG elements and compare that path with the reported working div case. Done means both bounds forms behave correctly for the SVG example without the parent-bound error.

Written by the indexing model from the issue text.

Description

Hi below is a very simple replication of the use case i am trying to do. I can confirm that bounds work with regular divs, but once i switch the exact same setting to within svg, it doesn't work anymore

using bounds="parent" will error out.
using bounds="#mostouter" wouldn't error out, but feature is ineffective.


export const test = function(){
	return (<div id="mostouter" style={{width:"600px", height:"600px", background:"pink"}}>
		<div style={{width:"500px", height:"500px", background:"teal"}}>
			<svg style={{overflow:'visible'}}>
				<Draggable bounds="#mostouter"> //{{right: 300, bottom: 300}} works
					<g>	
					<rect
						width={50}
						height={50}
						rx="10"
						ry="10"
						style={{ fill: "rgba(0,0,0,0.5)" }}
					></rect>
					</g>
				</Draggable>
				
			</svg>
		</div>

	</div>)
}
Dominant language
JavaScript
Stars
9.3k
Forks
1k
Avg merge
3d 8h
Merged PRs (30d)
4

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from react-grid-layout/react-draggable

All issues in react-grid-layout/react-draggable

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.