Skip to content

Commit

Permalink
Merge pull request openfoodfoundation#11837 from binarygit/open-link-…
Browse files Browse the repository at this point in the history
…in-new-page

Open external link in product description inside new page
  • Loading branch information
drummer83 authored Nov 28, 2023
2 parents 40742d6 + 208cad9 commit d4cebfd
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/views/shop/products/_summary.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
%h3
%a{"ng-click" => "triggerProductModal()", href: 'javascript:void(0)'}
%span{"ng-bind" => "::product.name"}
.product-description{ng: {"bind-html": "::product.description_html", click: "triggerProductModal()", show: "product.description_html.length"}}
.product-description{ng: {"bind-html": "::product.description_html", click: "triggerProductModal()", show: "product.description_html.length"}, "data-controller": "add-blank-to-link"}
%div{ "ng-switch" => "enterprise.visible" }
.product-producer
= t :products_from
Expand Down
8 changes: 8 additions & 0 deletions spec/system/consumer/shopping/products_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,14 @@
expect(page).to have_content "alert('Dangerous!'); Safe"
end
end

it "opens link in product description inside another window" do
product.description = "<a href='https://api.rubyonrails.org/'>external site</a>"
product.save!

visit shop_path
expect(find_link('external site')[:target]).to eq('_blank')
end
end

describe "filtering" do
Expand Down

0 comments on commit d4cebfd

Please sign in to comment.