block-components icon indicating copy to clipboard operation
block-components copied to clipboard

Search content when at least 3 letters typed in ContentSearch component

Open vishalkakadiya opened this issue 1 year ago • 3 comments

Description of the Change

Adds functionality to search the content when at least three letters are typed in the ContentSearch's component search functionality, so we can save network bandwidth.

How to test the Change

  • Add the "Post Searcher" component to the page.
  • Type just one letter the REST API is firing, so it is good practice to fire a REST request when at least three letters are added in the search.

Changelog Entry

Added - Add functionality to search the content when at least three letters are typed in the ContentSearch's search component.

Credits

Props @vishalkakadiya

vishalkakadiya avatar Jun 16 '23 16:06 vishalkakadiya

Hey @vishalkakadiya thanks for raising this!

While I sort of agree with your point, this would be a breaking change since usage could be relying on this. IMHO in the admin scenario in which lots of things are requesting data without you even knowing it's not the end of the world for this to happen.

I think as it stands we wouldn't go with this change. One way I can see to make this potentially work is by adding a prop. Something like: minQueryChars which by default is 0 so it would match but you'd have control to make that number 3 or whatever the number makes sense for your site.

Thoughts?

Antonio-Laguna avatar Jun 17 '23 09:06 Antonio-Laguna

@Antonio-Laguna Thank you for quickly checking on this. 🙌

Yes, it totally makes sense to build this as the props, let me know if you want me to update this PR to work with that prop.

Thanks! 🙂

vishalkakadiya avatar Jun 19 '23 06:06 vishalkakadiya

@vishalkakadiya please go ahead! Thanks for be willing to tackle this!

Antonio-Laguna avatar Jun 19 '23 07:06 Antonio-Laguna