motiondivision / motiondivision/motion
[BUG] `onClick` of `Reorder` component
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 33.7k
- Forks
- 1.4k
- Avg merge
- 1d 10h
- Merged PRs (30d)
- 14
Description
1. Describe the bug
The onClick event for the Reorder component occurs without any consistent rules.
2. IMPORTANT: Provide a CodeSandbox reproduction of the bug
3. Steps to reproduce
Steps to reproduce the behavior:
- Drag the upper item below the lower item - nothing happens
- Drag the lower item over the upper item - alert occurs
4. Expected behavior
onClick event should occur or should not occur for both behaviors.
5. Video or screenshots
https://github.com/framer/motion/assets/100757008/458bbf80-630c-4db7-839a-559c4356dce2
6. Notes
I'm currently dealing with this issue by using useRef.
const isJustReordered = useRef(false);
const onReorder = ( ... ) => {
...
isJustReordered.current = true;
}
return (
<Reorder.Group
...
onReorder={onReorder}>
{ ...
<Reorder.Item
...
onClick={() => {
if (isJustReordered.current) {
isJustReordered.current = false;
return;
}
// do something
}}
>
...
}
)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the CodeSandbox reproduction and inspect src/Item.tsx and src/index.tsx, especially the Reorder.Item onClick and drag/reorder setup. Compare both drag directions and define the intended click behavior; done means the event behaves consistently in each case with regression coverage for the reported scenarios.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- react, typescript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100