glide-data-grid icon indicating copy to clipboard operation
glide-data-grid copied to clipboard

onPaste does not fill all selected rows

Open DusanNikcevic opened this issue 2 years ago • 8 comments

Currently, I am working on a table with a company that expects almost identical Excel behavior. One missing thing is copying and pasting one row into multiple selected rows. Is this a feature that you intend to add or is this something you might delegate to devs using your library to implement themselves due to some technical complexity/edge cases?

Also if I am not mistaken, onPaste is currently working with onCellEdited, is this something that can be moved to onCellsEdited? That would greatly improve DX

DusanNikcevic avatar Aug 15 '22 14:08 DusanNikcevic

In my quick test onCellsEdited gets called for both onPaste and fillHandle

pzcfg avatar Aug 17 '22 22:08 pzcfg

In my quick test onCellsEdited gets called for both onPaste and fillHandle

that is good to know. thanks @pzcfg !

DusanNikcevic avatar Aug 17 '22 22:08 DusanNikcevic

Implementation proposal:

interface DataEditorProps {
  ...otherCrap,
  onPasteBehavior: undfined | {
    demuxRows: boolean,
    demuxColumns: boolean,
    demuxRanges: boolean,
  }
}

jassmith avatar Aug 24 '22 15:08 jassmith

Imo it would be nice to have onPaste trigger only onCellsEdited (or give the choice to the user as you proposed). That way we can have centralized logic in onCellsEdited for everything from actually editing to pasting events. It would improve DX but also performance without having to manually prevent events from happening.

DusanNikcevic avatar Aug 24 '22 15:08 DusanNikcevic

I dont understand why you think that would be better.

jassmith avatar Aug 24 '22 15:08 jassmith

Now we have to maintain both onCellsEdited and onCellEdited. Sure, we can prevent onPaste from triggering onCellEdited but IMO onCellEdited is kinda redundant anyway, since we have to maintain basically two functions to handle data change. I believe that it would be best if we could decide if we want to use one or the other, for example I would rather handle everything in onCellsEdited, but that depends on the use case, etc. So having an option to opt-in into one of these 2 functions would be ideal from DX perspective

DusanNikcevic avatar Aug 24 '22 16:08 DusanNikcevic

onCellsEdited was updated in 5.0.1 to always trigger, you can not implement onCellEdited at all if you like. onCellEdited will always trigger if onCellsEdited triggered.

jassmith avatar Aug 24 '22 16:08 jassmith

Ah well, in that case, everything is solved basically. Great stuff!

DusanNikcevic avatar Aug 24 '22 16:08 DusanNikcevic

This is as good as its going to get for a bit in 6.0.0. It now handles ranges much better. We might do more improvements in the future with pattern filling and handlng demuxing.

jassmith avatar Dec 18 '23 06:12 jassmith