react-sortable-hoc icon indicating copy to clipboard operation
react-sortable-hoc copied to clipboard

Add Placeholders Node where the Drop would happen

Open kellertobias opened this issue 7 years ago • 11 comments
trafficstars

I have just rewritten the sorting part of an application, I am developing in React and stumbled upon your "react-sortable-hoc". Before we used jqueryUI.

I am sorting a List (that's displayed as a grid).

Before we showed a placeholder in the spot where the item would be dropped. However, I haven't figured out a clever way to do this using your package.

Old Behaviour with Placeholders Old "Correct" Behaviour

New Behaviour without Placeholders New "Faulty" behaviour

kellertobias avatar Jul 27 '18 16:07 kellertobias

I just started working on something similar to this. There doesn't appear to be an easy way to do this. I'm thinking it may be possible to:

  • useDragHandle inserts a dummy element in the original indexValue of the list, styled how you want (a placeholder)
  • onSortEnd looks for the the placeholder in the list, and deletes it.

Only problem is DragHandle seems to fire on any event for all list elements. In my case each element contains in an input field. Editing one field (say in a list of two) useDragHandle fires twice for each key stroke.

Did you ever come up with a solution? I think I'm close...

const DragHandle = SortableHandle((indexValue) => {
  console.log(indexValue)
  // should inset dummy element to indexValue here
  return (
    <div className='grabHandle'/>
  )
})

const SortableItem = SortableElement(({value, indexValue, onEdit, onRemove}) => {
  return (
    <Segment compact textAlign='left' className='horizontal'>
      <DragHandle indexValue={indexValue}/>
      <Input name={indexValue} value={value} placeholder={value} className='grabHandleInput' onChange={onEdit}/>
    ... SNIP ...
    </Segment>
    );
  }
);

mr-remington avatar Dec 27 '18 22:12 mr-remington

Nope, no solution.

kellertobias avatar Dec 27 '18 22:12 kellertobias

Has anyone else seen this solved in the wild?

mismith avatar Jun 19 '19 19:06 mismith

I am having same issue Does anyone fond solution for this?

dbhalalahutwork avatar Aug 20 '19 04:08 dbhalalahutwork

Unfortunately, the absence of placeholder functionality is blocking me from using this awesome library in my project.

egorzekov avatar Sep 05 '19 07:09 egorzekov

Unfortunately, the absence of placeholder functionality is blocking me from using this awesome library in my project.

Same here +1

kaleem-elahi avatar Dec 10 '19 07:12 kaleem-elahi

@remingtonlang did you found any solution friend ?

kaleem-elahi avatar Dec 11 '19 14:12 kaleem-elahi

Me Too, please update if there is any droppable zone/ placeholder available in the future, would be awesome to have it

erezactionbar avatar Jan 07 '20 10:01 erezactionbar

I see this ticket's been open for well over a year. Has anyone figured out a sustainable workaround?

virsaviya avatar Feb 13 '20 20:02 virsaviya

I'm thinking of a similar thing. Let's say we have a list of items. There will be a Trashcan and anything dropped there would be deleted. Anyone got any ideas for that?

HardeepAsrani avatar Jul 17 '20 22:07 HardeepAsrani

any update on this feature?

Shubhdeep12 avatar Apr 14 '22 07:04 Shubhdeep12