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

Support more search form fields in Instant Results #2978

Open
JakePT opened this issue Sep 2, 2022 · 0 comments
Open

Support more search form fields in Instant Results #2978

JakePT opened this issue Sep 2, 2022 · 0 comments
Labels
enhancement front end Issues mostly related to the Front End like JavaScript/React and CSS. low priority module:instant-results Issues related to the Instant Results functionality
Milestone

Comments

@JakePT
Copy link
Contributor

JakePT commented Sep 2, 2022

Is your enhancement related to a problem? Please describe.
Currently the Instant Results modal is opened by submitting a form containing a search input. This opens the modal and sets the search term in Instant Results. Additionally, if any fields with the name post_type are found, this will be used to apply a post type filter in Instant Results.

The problem is that these are the only two fields supported, so if a form has a category dropdown or sorting option, any selections in those fields would not be reflected in Instant Results.

Describe the solution you'd like
At the moment we manually check for those two fields and set them as search arguments when the modal is opened. We could support any field that uses the name of our parameters by converting the form data to URL parameters and passing those through the existing getArgsFromUrlParams() function that's used for history navigation.

This would enable support for setting more search parameters from a search form, but Instant Results doesn't always use the same parameter names that pre-existing search forms might. For example, a default wp_dropdown_categories() will use the name cat, but Instant Results expects the parameter tax-category for filtering by category.

So if we want to support Instant Results for existing search forms not built with Instant Results in mind, or even future changes to the search block as outlined on WordPress/gutenberg#40585, we will need to map WordPress query vars to our parameter names.

Additional context
Related to #2507.

@JakePT JakePT added enhancement front end Issues mostly related to the Front End like JavaScript/React and CSS. module:instant-results Issues related to the Instant Results functionality labels Sep 2, 2022
@JakePT JakePT added this to the 4.4.0 milestone Sep 2, 2022
@JakePT JakePT self-assigned this Sep 2, 2022
@felipeelia felipeelia modified the milestones: 4.4.0, 4.5.0 Nov 3, 2022
@felipeelia felipeelia modified the milestones: 4.5.0, 5.0.0 Mar 1, 2023
@felipeelia felipeelia modified the milestones: 5.0.0, 5.1.0 Oct 6, 2023
@felipeelia felipeelia modified the milestones: 5.1.0, 5.2.0 Feb 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement front end Issues mostly related to the Front End like JavaScript/React and CSS. low priority module:instant-results Issues related to the Instant Results functionality
Projects
None yet
Development

No branches or pull requests

2 participants