motiondivision / motiondivision/motion

[BUG] `onClick` of `Reorder` component

Open
#2,682 1 comment 5 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
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

CodeSandbox

3. Steps to reproduce

Steps to reproduce the behavior:

  1. Drag the upper item below the lower item - nothing happens
  2. 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

Open the contributing guide

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.

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.