selecto icon indicating copy to clipboard operation
selecto copied to clipboard

If the mouse is within a selectable node, hitRate doesn't work as expected

Open SimeonRolev opened this issue 9 months ago • 1 comments

Environments

  • Framework name: react-selecto
  • Framework version: 1.26.0
  • Component name:
  • Component version:
  • Testable Address(optional):

Description

Issue and reproduction

The example from the documentation could be used as a reproduction:

  1. Set hitRate={100}. (the value doesn't actually matter, but 100 is the most obvious for the sake of the example)
  2. Start a dragging selection from outside
  3. The box becomes selected the moment the mouse enters it. It ignores the requirement for 100% coverage. https://codesandbox.io/s/85wdcj

Expected behavior

The box gets selected only if it's fully covered by the blue selection rectangle.

My workaround

selectFromInside={false} doesn't seem to change this. Strangely enough selectByClick={false} seems to fix it, but in that case the regular click-select stops working. So, I did this:

      const [isDragging, setIsDragging] = useState(false);

    /* ... */
        <Selecto
          selectableTargets={[".selectable"]}
          hitRate={100}
          selectByClick={!isDragging}
          onDrag={() => setIsDragging(true)}
          onDragEnd={() => setIsDragging(false)}
          toggleContinueSelect={'shift'}
          onSelect={({ selected }) => {
            setSelection(selected)
          }}
        />

This worked for my case, but seems more like a hack, at least the used properties' names don't state what they actually do. Is there a better way to achieve this?

Thanks!

SimeonRolev avatar Sep 20 '23 15:09 SimeonRolev

@SimeonRolev

  • lit-selecto 1.26.1
  • preact-selecto 1.23.1
  • react-selecto 1.26.1
  • selecto 1.26.1
  • svelte-selecto 1.26.1
  • vue-selecto 1.26.1
  • vue3-selecto 1.12.1
  • ngx-selecto 1.26.1

selecto's new version is released.

daybrush avatar Nov 11 '23 05:11 daybrush