-
Notifications
You must be signed in to change notification settings - Fork 314
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
Allow more control over which forms trigger Instant Results #2507
Comments
Instant Results is currently launched by submitting any form that contains an We could allow a user to enter a selector like Instead of/in addition to a selector field I think we should expose a JavaScript function that can be used to open the Instant Results modal and populate query args. Developers could then set default arguments of the query with their own values or by populating the arguments with values from their form. So something like this would be possible:
We would then update Instant Results to use this function ourselves for the default behaviour and add support for automatically setting arguments based on any inputs for I think this would also be an opportunity to try and decouple Instant Results from the modal, so that we can theoretically support embedding Instant Results as a block or similar without the modal. |
On discovery I think we can break this down and handle this task in two parts, and move decoupling Instant Results from the modal into a separate issue. The two things that need to be done here:
I will file a new issue for #2, and another issue for decoupling Instant Results from the modal, and we can proceed with #1 to progress this issue. |
Created #2979 for decoupling Instant Results from the modal. |
Is your enhancement related to a problem? Please describe.
Currently, Instant Results is attached to any
input[name="s"]
elements on the page, and triggered whenever the form that contains this input is submitted. This targets the Search widget, block, the output ofget_search_form()
in most themes, and any form that submits a query that includes the standard WordPress search parameter (s
).Therefore it's not currently possible to remove Instant Results from specific search form instances, or to bind it to other forms or even buttons.
A potential use case for this is that because Instant Results only has a single configuration for facets, the user may want to only enable it for Products search.
Describe the solution you'd like
There are several options for addressing this:
Implementation of any solution is slightly more complicated compare to Autosuggest, as the current behaviour requires a form and an input, as Instant Results is displayed based on the submit event on the form, but the search term is pulled from the instance of the input in that form.
If an API were exposed it would need the capability to not only open the Instant Results modal, but also to potentially populate the search term and other parameters.
The text was updated successfully, but these errors were encountered: