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

invalidDrop does not exist on dndState #5

Closed
multiplehats opened this issue Nov 26, 2024 · 2 comments · Fixed by #10
Closed

invalidDrop does not exist on dndState #5

multiplehats opened this issue Nov 26, 2024 · 2 comments · Fixed by #10
Assignees
Labels
bug Something isn't working enhancement New feature or request

Comments

@multiplehats
Copy link

I need to do some conditional checking, but i see that invalidDrop does not exist on the dndState, neither anywhere in the codebase.

Am I missing something?

@colecrouter
Copy link
Contributor

Looking at the docs, it seems like you're supposed to be setting it manually, e.g.:

function handleDragOver(state: DragDropState<Item>) {
  const { draggedItem } = state;
  // Prevent dropping if item doesn't meet criteria
  if (!isValidItem(draggedItem)) {
    // Optionally, add a class to indicate invalid drop target
    dndState.invalidDrop = true;
  } else {
    dndState.invalidDrop = false;
  }
}

Of course, setting arbitrary properties on the global state object isn't ideal or type-safe, but seems like it should work.

@Spikeysanju Spikeysanju self-assigned this Dec 12, 2024
@Spikeysanju Spikeysanju added bug Something isn't working enhancement New feature or request labels Dec 12, 2024
@Spikeysanju
Copy link
Contributor

@multiplehats This is fixed in @thisux/[email protected].

I’ve added support for invalidDrop in the dndState to enable conditional checking.
Here's an example to help you get started:

Code Example → Conditional Check
Demo → Conditional Check

Update to the latest version and try it out. Let me know if you need help.

Cheers,
@Spikeysanju

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants