From 2f745f77bca196a4a565777d1a659d263a3ede50 Mon Sep 17 00:00:00 2001
From: Michael Lee <lee.5151@osu.edu>
Date: Wed, 14 Aug 2024 13:13:12 -0400
Subject: [PATCH] Add check to preprocess file link hook to not run on webforms

---
 .../asc_bootstrap_bux/asc_bootstrap_bux.theme     | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/web/themes/asc_bootstrap_bux/asc_bootstrap_bux.theme b/web/themes/asc_bootstrap_bux/asc_bootstrap_bux.theme
index efff413f99..37e069694d 100755
--- a/web/themes/asc_bootstrap_bux/asc_bootstrap_bux.theme
+++ b/web/themes/asc_bootstrap_bux/asc_bootstrap_bux.theme
@@ -1147,11 +1147,14 @@ function asc_bootstrap_bux_preprocess_views_exposed_form(&$variables)
  */
 function asc_bootstrap_bux_preprocess_file_link(array &$variables)
 {
-  $link = $variables['link'];
-  $attributes = $link->getUrl()->getOption('attributes');
-  if (isset($attributes['target']) && $attributes['target'] === '_blank') {
-    $string = $link->getText();
-    $string .= " (opens in a new window)";
-    $link->setText($string);
+  $route_name = \Drupal::routeMatch()->getRouteName();
+  if ($route_name !== "entity.webform.canonical") {
+    $link = $variables['link'];
+    $attributes = $link->getUrl()->getOption('attributes');
+    if (isset($attributes['target']) && $attributes['target'] === '_blank') {
+      $string = $link->getText();
+      $string .= " (opens in a new window)";
+      $link->setText($string);
+    }
   }
 }
-- 
GitLab