diff --git a/app/views/vehicles/_details.html.erb b/app/views/vehicles/_details.html.erb
index 097a6f4..cc0c538 100644
--- a/app/views/vehicles/_details.html.erb
+++ b/app/views/vehicles/_details.html.erb
@@ -18,7 +18,7 @@
| <%= t(:field_vin) %> |
-
+ |
<%= @vin[0] if @vin %><%=@vin[1] if @vin%>
|
diff --git a/app/views/vehicles/_list.html.erb b/app/views/vehicles/_list.html.erb
index f8ce393..096e6a1 100644
--- a/app/views/vehicles/_list.html.erb
+++ b/app/views/vehicles/_list.html.erb
@@ -12,7 +12,7 @@
diff --git a/assets/javascripts/copy.js b/assets/javascripts/copy.js
index 4329800..adf0bf3 100644
--- a/assets/javascripts/copy.js
+++ b/assets/javascripts/copy.js
@@ -1,17 +1,25 @@
async function handleCopy(event) {
console.log("Copy link clicked");
+
// 1. Prevent the link from actually navigating
event.preventDefault();
-
- // 2. Grab the text from our span
- const text = document.getElementById('vin').innerText;
+
+ let text;
+ let link;
+ // 2. Grab the text from our clicked link
+ if(event.target.tagName.toLowerCase() === 'b'){
+ text = event.target.parentElement.innerText;
+ link = event.target.parentElement;
+ } else {
+ text = event.target.innerText;
+ link = event.target;
+ }
try {
// 3. Write to clipboard
await navigator.clipboard.writeText(text);
// 4. Update the UI to show it worked
- const link = event.target;
const originalText = link.innerText;
link.innerHTML = "Copied!";
link.style.color = "#4CAF50"; // Turn green