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

Feature Request: Replace all (within the Search feature)

Open TravisL12 opened this issue 1 year ago • 4 comments

I was asked to implement a search function in our grid editor, which is built in and works like a charm!

But I also have been asked for a "replace all" feature which I haven't found any obvious ways to do this. Is this possible currently and/or if not, could such a feature be introduced.

TravisL12 avatar Sep 19 '23 18:09 TravisL12

how would you like this to work?

jassmith avatar Sep 19 '23 20:09 jassmith

I was envisioning a similar UI to what is in VSCode for find/replace: image

Based on what the current search input looks like, there could be a toggle (kebab/meatball) icon that would display the "replace" input box beneath the current search input (probably would require a "Replace All" button to confirm the action): image

As for the API for this I propose a new prop: onSearchReplaceAll. This prop would act as both a boolean to enable the kebab toggle icon from being displayed as well as the callback function that get's called when the "Replace All" button is clicked.

TResultItem = {
  location: Item,
  cell: GridCell
}
onSearchReplaceAll?: ((replaceValue: string, results: TResultItem[]) => boolean)

This callback would provide the locations of cells that the search finds along with the replacement string from the "Replace" input box. The user would then be responsible for updating all found results with the replaceValue so they can update the state of their component as is compatible with their implementation (similar to how onPaste currently works).

Sorry for the poor mock attempt on this, but hope it gets my vision across.

TravisL12 avatar Sep 20 '23 18:09 TravisL12

Hmmm I will take a look at this as I'm about to be stuck on a plane over the atlantic anyway. Pray for me, if I'm lucky the plane will go down and I wont have to endure british cooking.

jassmith avatar Oct 02 '23 01:10 jassmith

It's dangerous to go alone. Take this! 🌯 (mission style burrito)

thanks @jassmith!

TravisL12 avatar Oct 02 '23 02:10 TravisL12