Skip to content

Fixed PHP autosuggest placeholder is not being used. #1619

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

Open
wants to merge 7 commits into
base: develop
Choose a base branch
from

Conversation

fabianmarz
Copy link
Contributor

@fabianmarz fabianmarz commented Jan 10, 2020

Description of the Change

  • While the autosuggest search string placeholder value can be changed via a PHP hook, it's not picked up by the autosuggest JS and therefore the query will break or doesn't deliver the correct results.

Alternate Designs

  • Instead of deleting const placeholder = 'ep_autosuggest_placeholder'; I considered using const placeholder = queryJSON.placeholder; but decided to drop the line completely as the placeholder is used in buildSearchQuery() only.

Benefits

  • Don't break any the results if other than the default value is used :)

Possible Drawbacks

  • X

Verification Process

  • Inspected the query after the search and replace was done to ensure the query runs with the actual search term.

Changelog Entry

Fixed - Autosuggest doesn't work if the placeholder is changed via a ep_autosuggest_query_placeholder filter.

Credits

Props @fabianmarz @burhandodhy

Checklist:

  • I have read the CONTRIBUTING document.
  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my change.
  • All new and existing tests passed.

Applicable Issues

  • Didn't find any.

Changelog Entry

Sorry, something went wrong.

@tlovett1
Copy link
Member

@mustafauysal can you review this one?

@mustafauysal
Copy link
Contributor

@tlovett1 looks good to me 👍

@felipeelia felipeelia added this to the 5.3.0 milestone Mar 20, 2025
@felipeelia
Copy link
Member

This PR will need to be refreshed and have tests added. Setting it to EP 5.3.0.

@burhandodhy burhandodhy self-assigned this Apr 21, 2025
@burhandodhy burhandodhy requested a review from Copilot April 21, 2025 16:23
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes an issue with the autosuggest feature where a custom PHP placeholder value was not being applied in the JavaScript query. Key changes include:

  • Removing the redundant placeholder parameter from the buildSearchQuery function.
  • Updating the query to use the global placeholder from epas.
  • Adding a Cypress test to verify that the autosuggest feature works correctly with a custom placeholder.

Reviewed Changes

Copilot reviewed 2 out of 4 changed files in this pull request and generated no comments.

File Description
tests/cypress/integration/features/autosuggest.cy.js Added a test case to ensure that the autosuggest feature works with the custom placeholder.
assets/js/autosuggest/index.js Removed the unused placeholder parameter from buildSearchQuery and updated the replacement logic to use epas.placeholder.
Files not reviewed (2)
  • .wp-env.json: Language not supported
  • tests/cypress/wordpress-files/test-plugins/custom-autosuggest-placeholder.php: Language not supported

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants