grid-js / gridjs

Advanced table plugin
https://gridjs.io
MIT License
4.39k stars 240 forks source link

Search box reset icon not clearing the search term (server side search) #1455

Open mbolli opened 3 months ago

mbolli commented 3 months ago

Describe the bug

When clicking the reset icon in the search box:

I'm tracking pagination, search and sort in a URLSearchParams object, which is appended to the request url on each request. If the search.server.url method is not called when resetting the search box, the request that is executed is the same as before.

        search: {
            server: {
                url: (prevUrl: string, keyword: string) => {
                    this.query.set('search', keyword);
                    return `${this.config.dataUrl}?${this.query.toString()}`;
                },
            },
        },

To Reproduce Steps to reproduce the behavior:

  1. Setup server side search
  2. Enter search term -> search.server.url is called with keyword = search term
  3. Reset search term -> search.server.url is not called

Expected behavior I'd expect the search.server.url method to be called on every search input change/input