Skip to content

Conversation

@mmestiyak
Copy link

feat(modifiers): add restrictToSpecificParent modifier

Add a new modifier that restricts dragging within a specific parent element's boundaries using React refs. This modifier is useful when you need to constrain movement to a container that isn't the immediate parent.

Features:

  • Restrict dragging within any specified parent element
  • Follows the same pattern as other dnd-kit modifiers
  • Fully typed with TypeScript

Example usage:

const containerRef = useRef(null);

<DndContext modifiers={[
  restrictToSpecificParent({ parentRef: containerRef })
]}>
  {/* draggable content */}
</DndContext>

@changeset-bot
Copy link

changeset-bot bot commented Feb 20, 2025

🦋 Changeset detected

Latest commit: 11334a5

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@dnd-kit/modifiers Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant