Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re-submitting filter form duplicates _x querystring arguments #1214

Closed
simonw opened this issue Feb 2, 2021 · 3 comments
Closed

Re-submitting filter form duplicates _x querystring arguments #1214

simonw opened this issue Feb 2, 2021 · 3 comments
Labels

Comments

@simonw
Copy link
Owner

simonw commented Feb 2, 2021

Really nasty bug, caused by #1194 fix in 07e1635

Navigate to this page: https://github-to-sqlite.dogsheep.net/github/labels?_search=help&_sort=id

Click "Apply" to submit the form and the resulting URL is https://github-to-sqlite.dogsheep.net/github/labels?_search=help&_sort=id&_search=help&_sort=id

That's because the (truncated) HTML for the form looks like this:

    ... <input id="_search" type="search" name="_search" value="help">
    ...
            <div class="select-wrapper small-screen-only">
                <select name="_sort" id="sort_by">
                    <option value="">Sort...</option>
                            <option value="id" selected>Sort by id</option>
                            <option value="node_id">Sort by node_id</option>
                            ...
                </select>
            </div>
            ...
            <input type="hidden" name="_search" value="help">
            <input type="hidden" name="_sort" value="id">
        <input type="submit" value="Apply">
@simonw simonw added the bug label Feb 2, 2021
@simonw
Copy link
Owner Author

simonw commented Feb 2, 2021

As a result, navigating to https://github-to-sqlite.dogsheep.net/github/labels?_search=help and clearing out the _search field then submitting the form does NOT clear the search term.

@simonw
Copy link
Owner Author

simonw commented Feb 2, 2021

The cause of this bug is form fields which begin with _ but ARE displayed as form inputs on the page - hence should not be duplicated in an <input type="hidden"> element.

@simonw simonw closed this as completed in 7a2ed9f Feb 2, 2021
simonw added a commit that referenced this issue Feb 2, 2021
simonw added a commit that referenced this issue Feb 2, 2021
@simonw
Copy link
Owner Author

simonw commented Feb 2, 2021

Fix is now live on https://latest.datasette.io/fixtures/searchable?_search=terry - clearing "terry" and re-submitting the form now works as expected.

simonw added a commit that referenced this issue Feb 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant