Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(modifiers): add restrictToSpecificParent modifier #1613

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

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>

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