Preserve custom query parameters in index search forms#7639
Open
BriceFab wants to merge 1 commit into
Open
Conversation
dd1f248 to
b4bac0d
Compare
GET search forms discard the action URL query string in browsers. Reuse the same hidden-field approach already used for filters and the filters modal so custom context parameters (e.g. menu-driven list views) and sort state survive search submissions. Fixes EasyCorp#7640 Related to EasyCorp#1573, EasyCorp#4707
b4bac0d to
da8696a
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #7640
Summary
Browsers discard the query string of GET forms when they are submitted. EasyAdmin already works around this for:
filters[...]parameters (hidden fields insearch_form_filters, see [3.5.9] Searching does not respect active filters #4707)form_action_query_string_as_array|ea_flatten_arrayinfilters.html.twig)However, other query parameters (custom menu context like
_status, sort state, etc.) are preserved in links generated byAdminUrlGenerator, but lost when submitting the index search form in real browsers. This has been known since #1573.This PR generalizes the existing approach by preserving all remaining query parameters as hidden fields in the search form.
Changes
SearchDto::getPreservedQueryParameters()to return current query params minus reserved EasyAdmin keys (query,page,filters, batch params, etc.)layout.html.twig(same comment/pattern asfilters.html.twig)Test plan
SearchDtoTest::testGetPreservedQueryParametersSearchAllTermsTest::testSearchPreservesCustomQueryParametersRelated issues