From e4d33571ffb101b00ae24370738ef0221d6e5de4 Mon Sep 17 00:00:00 2001 From: Justin Coyne Date: Fri, 9 Feb 2024 11:01:50 -0600 Subject: [PATCH] Avoid Turbo prefetching (InstantClick) See https://turbo.hotwired.dev/handbook/drive\#instantclick Because we're changing the link into a form, we get no benefit from this and put unnecessary load on the server --- app/helpers/blacklight/url_helper_behavior.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/helpers/blacklight/url_helper_behavior.rb b/app/helpers/blacklight/url_helper_behavior.rb index c259311967..81dd88e19e 100644 --- a/app/helpers/blacklight/url_helper_behavior.rb +++ b/app/helpers/blacklight/url_helper_behavior.rb @@ -36,7 +36,8 @@ def document_link_params(doc, opts) private :document_link_params ## - # Attributes for a link that gives a URL we can use to track clicks for the current search session + # Attributes for a link that gives a URL we can use to track clicks for the current search session. + # We disable turbo prefetch (InstantClick), because since we replace the link with a form, it's just wasted. # @param [SolrDocument] document # @param [Integer] counter # @example @@ -52,7 +53,7 @@ def session_tracking_params document, counter, per_page: search_session['per_pag return {} if path.nil? context_method = blacklight_config.track_search_session.storage == 'client' ? 'get' : 'post' - { data: { context_href: path, context_method: context_method } } + { data: { context_href: path, context_method: context_method, turbo_prefetch: false } } end ##