jquense / react-big-calendar

gcal/outlook like calendar component
http://jquense.github.io/react-big-calendar/examples/index.html
MIT License
7.82k stars 2.23k forks source link

Action of "onSelectSlot" is "click" when minimal range selected #2457

Open abaksha-sc opened 11 months ago

abaksha-sc commented 11 months ago

Check that this is really a bug

Reproduction link

https://codesandbox.io/s/react-big-calendar-example-forked-fv8lkc?file=/src/App.js

Bug description

When slot is selected with a few pixels mouse movement then onSelectSlot provides action as click, but not select. Even when slot is really was selected:

image

Steps to repeat:

  1. Click and hold mouse near the event top border
  2. Slowly move mouse to bottom only for a few pixels while new event (with shadow, node ".rbc-slot-selection") is not appear
  3. Release your mouse

Expected Behavior

It should has action select.

Actual Behavior

It provides action click when slot was selected.

For example I ignore all click events and allow to add events with slot selection only. And because of this bug user disallows to add event with such small range.

react-big-calendar version

1.8.1

React version

18.2.0

Platform/Target and Browser Versions

Chrome

Validations

Would you like to open a PR for this bug?

abaksha-sc commented 11 months ago

For those who will find this issue I'll leave a fast and dirty workaround: https://codesandbox.io/s/react-big-calendar-example-forked-z8459t?file=/src/App.js

The idea is to detect if node .rbc-slot-selection was rendered:

onSelectSlot={(data) => {
        // when node 'rbc-slot-selection' exist that means the slot was selected, but not clicked
        const fixedAction =
          data.action === "click" &&
          document.querySelector(".rbc-slot-selection")
            ? "select"
            : data.action;

        // now use variable "fixedAction" instead of provided

UPD: but sometimes node .rbc-slot-selection disappears earlier than handler onSelectSlot calls :( So this workaround is not stable