WebDevStudios / wp-search-with-algolia

Improve search on your site. Autocomplete is included, along with full control over look, feel and relevance.
https://wordpress.org/plugins/wp-search-with-algolia/
146 stars 55 forks source link

Ctrl + click (or cmd + click on Mac) user names opens a 404 undefined page #292

Closed jamesoquendo closed 1 year ago

jamesoquendo commented 1 year ago

Describe the bug Doing a ctrl + click (or cmd + click on Mac) opens to a 404 undefined page.

To Reproduce Steps to reproduce the behavior:

  1. Go to https://www.couchbase.com/blog
  2. Click on the "Search Here" input field
  3. Enter any name to search for a user (i.e., James, Tim, Anne)
  4. Ctrl + click (or cmd + click) on a Users name under User
  5. observe that a 404 Not Found page opens with undefined in the URL

Expected behavior The URL of the user should open in a new tab

Screenshots Please see screenshots for reference

Screen Shot 2 Screen Shot 1

Desktop (please complete the following information):

Additional context Works fine in Safari.

tw2113 commented 1 year ago

Is this a site that's still in development? or is this one that's very much live? Asking because I'm wondering if we can enable SCRIPT_DEBUG to true so that we can keep the autocomplete dropdown open temporarily.

I'm curious if somehow there's event listeners being attached that have that undefined URL. For what it's worth I was able to get a new tab opened with the actual user's permalink, but at the same time the same window did go to the 404 page described above.

I'm also curious if you have some properties in your user index that are set to undefined somehow.

jamesoquendo commented 1 year ago

This site is live so we cannot edit directly on there, but I enabled SCRIPT_DEBUG on Staging at https://staging.couchbase.com/blog. I don't think there are any event listeners specific to a 'Ctrl + click' event since we don't have a need to do so. I don't see any undefined properties in the user index. the staging site has only 3 user records: shyamraj, James, and Madhuram. Please use one of those three names to search on our staging environment.

Example of record in User Index:

Screen Shot 4
tw2113 commented 1 year ago

Have you done any customizing to the template files for Autocomplete in general? Asking because I'm not seeing this block of script: https://github.com/WebDevStudios/wp-search-with-algolia/blob/main/templates/autocomplete.php#L74-L193

It's possible it got moved to elsewhere, or maybe if you have a caching plugin in place, it's doing some optimization as well. In fact, I think I may have found it all in https://staging.couchbase.com/blog/wp-content/cache/swift-performance/staging.couchbase.com/js/72ac3ec911a375dd15c43a684b23c5ac.js

That said, I think you may need to flush the cache as that file is showing debug as still set to false

jamesoquendo commented 1 year ago

We had a swift performance optimization tool that merged our scripts. I disabled that and cleared cache. Please clear cache and check or open a browser with incognito mode.

tw2113 commented 1 year ago

Definitely seeing the un-optimized version, but it's still showing debugging as false.

Instead of dinking around with SCRIPT_DEBUG since it seems to not be getting recognized so far, you could also temporarily edit the autocomplete.php template file and change it to this:

var config = {
    debug: true, // changed from algolia.debug
    hint: false,
    openOnFocus: true,
    appendTo: 'body',
    templates: {
        empty: wp.template( 'autocomplete-empty' )
    }
};
jamesoquendo commented 1 year ago

There are two files named autocomplete.php:

I updated both with the above debug: true, statement as you mentioned. These two files were uploaded to their respective plugins folders on the staging environment.

tw2113 commented 1 year ago

Looks like https://wordpress.org/plugins/search-by-algolia-instant-relevant-results/ is their old one and no longer relevant. I believe we forked from that one, originally. Worth removing that one from the install when you have a chance.

Regarding the rest, I'm not seeing any events tied to the individual suggestions from Autocomplete, so that theory is out the window.

I am seeing Unable to load ramble snippet: undefined from terminus-chat.js which may or may not be related. Worth temporarily removing and re-testing just in case. Otherwise, just something that can be disregarded.

I am also feeling like this may be a UX detail that is controlled by Algolia more than our specific plugin, and I have to believe that ctrl/cmd clicking the autocompletes may not be intended UX. They would be wanting to get the user to the individual results pages rather than open many from the suggestions. An instantsearch results page I could see being able to open many from that ctrl/cmd flow.

jamesoquendo commented 1 year ago

I can remove search by Algolia instant relevant results. Thanks for noting that.

I don't see an error coming from terminus-chat.js. Ramble snippet is related to the chatbot loading at the bottom right corner of the page. I don't think it's related.

The odd bit is that 'ctrl/cmd + click' works fine for links other than those under the Users category. Maybe there is some data missing somewhere within the index, or content, as you previously mentioned.

tw2113 commented 1 year ago

nothing that I can determine.

All the properties you can see in the screenshot from https://github.com/WebDevStudios/wp-search-with-algolia/issues/292#issuecomment-1401077719 correlate to the data object in the autocomplete template and specifically the user template https://github.com/WebDevStudios/wp-search-with-algolia/blob/main/templates/autocomplete.php#L48-L55 and I can tell from the view-source of the page, that you haven't customized that section at all.

For whatever it may be worth, I just tried on a test install and was able to recreate.

@asharirfan what do you think of this topic at hand?

tw2113 commented 1 year ago

@jamesoquendo Are you still experiencing this issue/error? If yes, could you see if the change made over at https://github.com/WebDevStudios/wp-search-with-algolia/pull/334/files#diff-bd07eb479cca898bf5465bfd70977fa2c7663f2248faa358e0344288394a1b4cR176 fixes the issue for you? It'd be a case of editing your own autocomplete.php template file briefly to help confirm.

Thanks.