Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

toggleContinueSelect not working (MacOS, Chrome) #167

Open
tomelliot opened this issue Mar 8, 2024 · 1 comment
Open

toggleContinueSelect not working (MacOS, Chrome) #167

tomelliot opened this issue Mar 8, 2024 · 1 comment

Comments

@tomelliot
Copy link

tomelliot commented Mar 8, 2024

Environments

Description

This could definitely be me not knowing the right way to use Selecto, but I'm seeing that I can't use the toggleContinueSelect to allow continuing to select. If a selection is present and I hold shift and either click or drag to add to the selection, then the selection is deselected. I can then create a new selection again. I'm finding it works as expected otherwise.

Here's the implementation, let me know if I can provide any more info:

<Selecto
            // The container to add a selection element
            container={assetSelectorRef.current}
            // Targets to select. You can register a queryselector or an Element.
            selectableTargets={[".target"]}
            // Whether to select by click (default: true)
            selectByClick={true}
            // Whether to select from the target inside (default: true)
            selectFromInside={true}
            // After the select, whether to select the next target with the selected target (deselected if the target is selected again).
            continueSelect={false}
            // Determines which key to continue selecting the next target via keydown and keyup.
            toggleContinueSelect="shift"
            // The container for keydown and keyup events
            keyContainer={assetSelectorRef.current}
            // The rate at which the target overlaps the drag area to be selected. (default: 100)
            hitRate={30}
            scrollOptions={{
              threshold: 40,
              container: assetSelectorRef,
              throttleTime: 20,
              checkScrollEvent: true,
            }}
            onScroll={({ direction, container }) => {
              container.scrollBy(direction[0] * 10, direction[1] * 10);
            }}
            onSelect={(e) => {
              if (state == "saving" || state == "generating") return;
              e.added.forEach((el) => {
                const assetId = el.dataset.assetid
                if (!assetId) return;
                handleSelectAssetId(assetId);
              });
              e.removed.forEach((el) => {
                const assetId = el.dataset.assetid
                if (!assetId) return
                handleDeselectAssetId(assetId);
              });
            }}
          />
@tomelliot
Copy link
Author

I'm seeing that the behaviour is different if I use toggleContinueSelect={[["shift"]]} (it seems to work) instead of toggleContinueSelect="shift". This is confusing - I'm not sure what I'm missing here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant