Skip to content

Using dndzone in v5 fails to reorder items #283

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

Closed
macsupport opened this issue Mar 16, 2025 · 2 comments
Closed

Using dndzone in v5 fails to reorder items #283

macsupport opened this issue Mar 16, 2025 · 2 comments
Labels
Stale waiting for input Currently waiting for OA's input to this issue

Comments

@macsupport
Copy link

macsupport commented Mar 16, 2025

I am updating my project to Svelte v5 and in the process I am updating also Svelecte as well. When trying to integrate dndzone, as in your example I get:

TypeError keepOriginalElementInDom@

dragging and dropping an item fails.

See this REPL: https://svelte.dev/playground/db538e69a85a4b42a106a67d40e40df7?version=5.23.0

This is my test code:

import Svelecte from 'svelecte';
let svelecte;
let selectedItems = [];

 import { dndzone, overrideItemIdKeyNameBeforeInitialisingDndZones, setDebugMode } from 'svelte-dnd-action';

     overrideItemIdKeyNameBeforeInitialisingDndZones('value');

    </script>

   <div class="svelecte-help relative w-full mx-1 md:w-1/2 md:mx-auto dark">
    <label class="text-xs">Click and Drag to Sort Drugs</label>

    <Svelecte 
  bind:this={svelecte}
  inputId="drugs"
  fetchMode="auto"
  name="drugSelection"
{dndzone}
  multiple
  bind:value={selectedItems}
  valueField="name"
  labelField="name"
  placeholder="Select Drugs" 

  closeAfterSelect={true}
  collapseSelection="blur"
  valueAsObject={true}
 strictMode={false}
fetch="https://vet-drugs.vetcalculators.workers.dev"
 fetchResetOnBlur={false} 
 minQuery={2} 

 >
</Svelecte>
 </div>
@mskocik
Copy link
Owner

mskocik commented Mar 16, 2025

Your overrideItemIdKeyNameBeforeInitialisingDndZones('value'); must match your valueField 👉 name. Seems you kept the one from docs example 😉

@mskocik mskocik added the waiting for input Currently waiting for OA's input to this issue label Apr 2, 2025
Copy link

This issue is stale because it has been open 21 days with no activity. Remove stale label or comment or this will be closed in 3 days.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Stale waiting for input Currently waiting for OA's input to this issue
Projects
None yet
Development

No branches or pull requests

2 participants