glide-data-grid
glide-data-grid copied to clipboard
Feature Request: Replace all (within the Search feature)
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.
how would you like this to work?
I was envisioning a similar UI to what is in VSCode for find/replace:
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):
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.
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.
It's dangerous to go alone. Take this! 🌯 (mission style burrito)
thanks @jassmith!