chore: port SnapCentertoCursor to experimental branch#1599
chore: port SnapCentertoCursor to experimental branch#1599khuezy wants to merge 4 commits intoclauderic:experimentalfrom
Conversation
|
a946bd3 to
96e60bf
Compare
|
@clauderic Does the |
|
You should be able to add a story here: apps/stories/stories/react/Draggable/Modifiers/Modifiers.stories.tsx Something like: export const SnapToCursor: Story = {
name: 'Snap to cursor',
args: {
modifiers: [SnapCenterToCursor],
},
}; |
Co-authored-by: Claudéric Demers <clauderic.d@gmail.com>
|
There is an issue w/ the typing when I apply the The code runs correctly but typescript complains. I'm using |
|
@khuezy There are two DragDropManager, one is from You can refer to |
|
The |
|
|
||
| interface Options { | ||
| size: number | {x: number; y: number}; | ||
| size: number | { x: number; y: number }; |
There was a problem hiding this comment.
I'm not sure why your editor isn't respecting the prettier settings, it should be:
{
"bracketSpacing": false,
"singleQuote": true,
"semi": true,
"trailingComma": "es5"
}
There was a problem hiding this comment.
Yea that's really strange. I see the prettier loading .prettierrc but it's not applying those settings.
When I run bun format, it picks up 28 file changes... Should I include that or just leave everything as it is for you to format.
Co-authored-by: Claudéric Demers <clauderic.d@gmail.com>
clauderic
left a comment
There was a problem hiding this comment.
Summary
This PR adds a SnapCenterToCursor modifier to @dnd-kit/abstract that offsets the drag transform so the element's center snaps to the cursor position. The implementation is straightforward and extends Modifier correctly.
Feedback
Blocking issues
-
Missing changeset:
packages/abstract/src/modifiers/snap.tsandpackages/abstract/src/modifiers/index.tswere modified with a new exported class, but there is no.changeset/*.mdfile in the diff. SinceSnapCenterToCursoris a new public export, a minor-level changeset for@dnd-kit/abstractis needed before this can be released:--- "@dnd-kit/abstract": minor --- Added SnapCenterToCursor modifier. -
Incorrect import path in story (
apps/stories/stories/react/Draggable/Modifiers/Modifiers.stories.tsx:3): The story importsSnapCenterToCursorfrom@dnd-kit/dom/modifiers, but the class is only exported from@dnd-kit/abstract/modifiers. Thepackages/dom/src/modifiers/index.tswas not updated to re-export it, so this import would fail at build time. Either:- Change the import to
@dnd-kit/abstract/modifiers, or - Add
SnapCenterToCursortopackages/dom/src/modifiers/index.ts(which would also need a changeset for@dnd-kit/dom)
- Change the import to
Suggestions
- The story file is missing a newline at the end of file (minor).
SnapCenterToCursordoes not implementstatic configure = configurator(SnapCenterToCursor). This is fine since this modifier takes no options, but it's worth confirming that's intentional.
Changeset
- Status: missing — a changeset for
@dnd-kit/abstractwith bump typeminoris required.
Overall
The SnapCenterToCursor modifier is a useful and requested feature. The core implementation looks correct. Once the changeset is added and the import path issue is fixed, this should be good to go. Thanks for contributing this, @khuezy!
[claude-review]
No description provided.