Add configurable minimum characters setting for autocomplete#508
Open
souleater2023 wants to merge 1 commit intoWebDevStudios:mainfrom
Open
Add configurable minimum characters setting for autocomplete#508souleater2023 wants to merge 1 commit intoWebDevStudios:mainfrom
souleater2023 wants to merge 1 commit intoWebDevStudios:mainfrom
Conversation
- Added algolia_autocomplete_min_chars setting with default of 3 characters - Added admin interface for configuration (1-10 character range) - Updated JavaScript to use minLength parameter in autocomplete.js - Added proper sanitization and validation - Maintains backward compatibility This feature reduces API calls to Algolia while maintaining good UX. Users can configure the minimum number of characters required before autocomplete search begins via WordPress Admin > Algolia Search > Autocomplete. Files modified: - includes/class-algolia-settings.php: Added setting and getter method - includes/indices/class-algolia-index.php: Added to default config - includes/admin/class-algolia-admin-page-autocomplete.php: Added admin interface - includes/class-algolia-template-loader.php: Pass setting to frontend - templates/autocomplete.php: Apply minLength to autocomplete.js config
Member
|
Definitely appreciate the PR for this. While I know you're wanting a minimum of 3 characters before executing, we should leave it at current default Also I believe we will want to get the changes for Looks like there's no minLength for Autocomplete version 1.x+, which we're trying to get moved to offering, but we can make use of the setting somehow and work with the template. |
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.
Summary
This PR adds a configurable minimum characters setting for autocomplete search to reduce API calls to Algolia.
Problem
Currently, autocomplete triggers on every keystroke starting from the first character, which can generate excessive API calls to Algolia, especially for sites with high search traffic.
Solution
This PR adds a configurable "Minimum Characters" setting that allows administrators to specify how many characters users must type before autocomplete search begins.
Changes
algolia_autocomplete_min_charssetting (default: 3 characters)minLengthparameterBenefits
Files Modified
includes/class-algolia-settings.php- Added setting and getter methodincludes/indices/class-algolia-index.php- Added to default configincludes/admin/class-algolia-admin-page-autocomplete.php- Added admin interfaceincludes/class-algolia-template-loader.php- Pass setting to frontendtemplates/autocomplete.php- Apply minLength to autocomplete.jsTesting
Usage
Navigate to WordPress Admin > Algolia Search > Autocomplete and configure the "Minimum Characters" field (default: 3).
This addresses the need to reduce API calls while maintaining good user experience.