Plugin Directory

Changeset 3817489


Ignore:
Timestamp:
11/23/2026 05:26:51 AM (less than one hour ago)
Author:
maidulcu
Message:

Release 2.0.10: no No results found flash while typing, stale replies ignored

Location:
searchjet-instant-search
Files:
8 edited
1 copied

Legend:

Unmodified
Added
Removed
  • searchjet-instant-search/tags/2.0.10/assets/js/searchjet-autocomplete.js

    r3644704 r3817489  
    6969    });
    7070
     71    // Typing timings. A reply can come back with 0 hits for a half-typed word ("hoddi") just before the
     72    // full word ("hoddie") matches, so "No results found" waits until typing has paused.
     73    const DEBOUNCE_MS = 150;
     74    const EMPTY_STATE_DELAY_MS = 300;
     75    let lastInputAt = 0;
     76    let emptyTimer = null;
     77
    7178    // Add custom search widget that uses existing input
    7279    search.addWidget({
    … …  
    7885                const query = this.value.trim();
    7986                clearTimeout(debounceTimer);
     87                clearTimeout(emptyTimer);
     88                lastInputAt = Date.now();
    8089               
    8190                if (!query) {
    … …  
    92101                    debounceTimer = setTimeout(() => {
    93102                        helper.setQuery(query).search();
    94                     }, 100);
     103                    }, DEBOUNCE_MS);
    95104                }
    96105            });
    97         },
    98         render({ results }) {
    99             // Show/hide results container based on query
    100             const hasQuery = results && results.query && results.query.trim();
    101             resultsContainer.style.display = hasQuery ? 'block' : 'none';
    102106        }
    103107    });
    104108
     109    // Only draw a reply that is for what is in the box now. Replies can arrive out of order, and a late
     110    // reply must not reopen the dropdown after the box was cleared. An empty reply is drawn only once
     111    // typing has paused; until then the last results stay on screen.
     112    function withReplyGuard(hitsWidget) {
     113        const renderHits = hitsWidget.render.bind(hitsWidget);
     114        hitsWidget.render = function (args) {
     115            const results = args && args.results;
     116            const query = results && typeof results.query === 'string' ? results.query.trim() : '';
     117            if (!query || query !== input.value.trim()) {
     118                return;
     119            }
     120            clearTimeout(emptyTimer);
     121
     122            const show = () => {
     123                renderHits(args);
     124                resultsContainer.style.display = 'block';
     125            };
     126            if (results.hits && results.hits.length) {
     127                show();
     128                return;
     129            }
     130            const wait = lastInputAt + EMPTY_STATE_DELAY_MS - Date.now();
     131            if (wait <= 0) {
     132                show();
     133                return;
     134            }
     135            emptyTimer = setTimeout(() => {
     136                if (query === input.value.trim()) {
     137                    show();
     138                }
     139            }, wait);
     140        };
     141        return hitsWidget;
     142    }
     143
    105144    // Add hits widget
    106145    search.addWidget(
    107         SearchJet.widgets.hits({
     146        withReplyGuard(SearchJet.widgets.hits({
    108147            container: '#searchjet-results',
    109148            templates: {
    … …  
    135174                return grouped;
    136175            }
    137         })
     176        }))
    138177    );
    139178
  • searchjet-instant-search/tags/2.0.10/assets/js/searchjet-federated.js

    r3816833 r3817489  
    109109    search.addWidget({
    110110        render({ results }) {
    111             if (!results || !results.query) {
     111            // Ignore a reply for a query that is no longer in the box (late or out-of-order reply,
     112            // or the box was cleared).
     113            if (!results || !results.query || results.query !== input.value.trim()) {
    112114                return;
    113115            }
  • searchjet-instant-search/tags/2.0.10/readme.txt

    r3816903 r3817489  
    55Tested up to: 7.1
    66Requires PHP: 7.4
    7 Stable tag: 2.0.9
     7Stable tag: 2.0.10
    88License: GPLv2 or later
    99License URI: https://www.gnu.org/licenses/gpl-2.0.html
    … …  
    118118
    119119== Changelog ==
     120
     121= 2.0.10 =
     122* Fix: the search dropdown no longer flashes "No results found" while you type (for example on the way to a typo like "hoddie"), and a slow reply for an earlier keystroke can no longer replace newer results or reopen a cleared search box.
    120123
    121124= 2.0.9 =
  • searchjet-instant-search/tags/2.0.10/searchjet.php

    r3816833 r3817489  
    44 * Plugin URI: https://searchjetengine.com/
    55 * Description: AI-powered instant search for WooCommerce & WordPress. Supports SKUs, smart filters, typo-tolerance & GA4 tracking.
    6  * Version: 2.0.9
     6 * Version: 2.0.10
    77 * Author: Maidul
    88 * Author URI: https://searchjetengine.com/
    … …  
    2424}
    2525// Define plugin constants
    26 define('SEARCHJET_VERSION', '2.0.9');
    27 define('SEARCHJET_PLUGIN_VERSION', '2.0.9');
     26define('SEARCHJET_VERSION', '2.0.10');
     27define('SEARCHJET_PLUGIN_VERSION', '2.0.10');
    2828define('SEARCHJET_PLUGIN_FILE', __FILE__);
    2929define('SEARCHJET_PLUGIN_DIR', plugin_dir_path(__FILE__));
  • searchjet-instant-search/trunk/assets/js/searchjet-autocomplete.js

    r3644704 r3817489  
    6969    });
    7070
     71    // Typing timings. A reply can come back with 0 hits for a half-typed word ("hoddi") just before the
     72    // full word ("hoddie") matches, so "No results found" waits until typing has paused.
     73    const DEBOUNCE_MS = 150;
     74    const EMPTY_STATE_DELAY_MS = 300;
     75    let lastInputAt = 0;
     76    let emptyTimer = null;
     77
    7178    // Add custom search widget that uses existing input
    7279    search.addWidget({
    … …  
    7885                const query = this.value.trim();
    7986                clearTimeout(debounceTimer);
     87                clearTimeout(emptyTimer);
     88                lastInputAt = Date.now();
    8089               
    8190                if (!query) {
    … …  
    92101                    debounceTimer = setTimeout(() => {
    93102                        helper.setQuery(query).search();
    94                     }, 100);
     103                    }, DEBOUNCE_MS);
    95104                }
    96105            });
    97         },
    98         render({ results }) {
    99             // Show/hide results container based on query
    100             const hasQuery = results && results.query && results.query.trim();
    101             resultsContainer.style.display = hasQuery ? 'block' : 'none';
    102106        }
    103107    });
    104108
     109    // Only draw a reply that is for what is in the box now. Replies can arrive out of order, and a late
     110    // reply must not reopen the dropdown after the box was cleared. An empty reply is drawn only once
     111    // typing has paused; until then the last results stay on screen.
     112    function withReplyGuard(hitsWidget) {
     113        const renderHits = hitsWidget.render.bind(hitsWidget);
     114        hitsWidget.render = function (args) {
     115            const results = args && args.results;
     116            const query = results && typeof results.query === 'string' ? results.query.trim() : '';
     117            if (!query || query !== input.value.trim()) {
     118                return;
     119            }
     120            clearTimeout(emptyTimer);
     121
     122            const show = () => {
     123                renderHits(args);
     124                resultsContainer.style.display = 'block';
     125            };
     126            if (results.hits && results.hits.length) {
     127                show();
     128                return;
     129            }
     130            const wait = lastInputAt + EMPTY_STATE_DELAY_MS - Date.now();
     131            if (wait <= 0) {
     132                show();
     133                return;
     134            }
     135            emptyTimer = setTimeout(() => {
     136                if (query === input.value.trim()) {
     137                    show();
     138                }
     139            }, wait);
     140        };
     141        return hitsWidget;
     142    }
     143
    105144    // Add hits widget
    106145    search.addWidget(
    107         SearchJet.widgets.hits({
     146        withReplyGuard(SearchJet.widgets.hits({
    108147            container: '#searchjet-results',
    109148            templates: {
    … …  
    135174                return grouped;
    136175            }
    137         })
     176        }))
    138177    );
    139178
  • searchjet-instant-search/trunk/assets/js/searchjet-federated.js

    r3816833 r3817489  
    109109    search.addWidget({
    110110        render({ results }) {
    111             if (!results || !results.query) {
     111            // Ignore a reply for a query that is no longer in the box (late or out-of-order reply,
     112            // or the box was cleared).
     113            if (!results || !results.query || results.query !== input.value.trim()) {
    112114                return;
    113115            }
  • searchjet-instant-search/trunk/readme.txt

    r3816903 r3817489  
    55Tested up to: 7.1
    66Requires PHP: 7.4
    7 Stable tag: 2.0.9
     7Stable tag: 2.0.10
    88License: GPLv2 or later
    99License URI: https://www.gnu.org/licenses/gpl-2.0.html
    … …  
    118118
    119119== Changelog ==
     120
     121= 2.0.10 =
     122* Fix: the search dropdown no longer flashes "No results found" while you type (for example on the way to a typo like "hoddie"), and a slow reply for an earlier keystroke can no longer replace newer results or reopen a cleared search box.
    120123
    121124= 2.0.9 =
  • searchjet-instant-search/trunk/searchjet.php

    r3816833 r3817489  
    44 * Plugin URI: https://searchjetengine.com/
    55 * Description: AI-powered instant search for WooCommerce & WordPress. Supports SKUs, smart filters, typo-tolerance & GA4 tracking.
    6  * Version: 2.0.9
     6 * Version: 2.0.10
    77 * Author: Maidul
    88 * Author URI: https://searchjetengine.com/
    … …  
    2424}
    2525// Define plugin constants
    26 define('SEARCHJET_VERSION', '2.0.9');
    27 define('SEARCHJET_PLUGIN_VERSION', '2.0.9');
     26define('SEARCHJET_VERSION', '2.0.10');
     27define('SEARCHJET_PLUGIN_VERSION', '2.0.10');
    2828define('SEARCHJET_PLUGIN_FILE', __FILE__);
    2929define('SEARCHJET_PLUGIN_DIR', plugin_dir_path(__FILE__));
Note: See TracChangeset for help on using the changeset viewer.