Skip to content

Commit

Permalink
fix: keep tippy title when browser back is used (#3284)
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul-Bob authored Sep 30, 2024
1 parent 9a6ac52 commit 9c91b75
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions app/javascript/avo.base.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,18 @@ function initTippy() {
tippy('[data-tippy="tooltip"]', {
theme: 'light',
content(reference) {
const title = reference.getAttribute('title')
reference.removeAttribute('title')
reference.removeAttribute('data-tippy')
// On fist load get the title
// Remove the title attribute from the element to avoid the default HTML title attribute behavior
// Add the title value to tippy_title attribute
// When browser back is clicked get the title from tippy_title
let title = reference.getAttribute('title')

if (title) {
reference.setAttribute('tippy_title', title)
reference.removeAttribute('title')
} else {
title = reference.getAttribute('tippy_title')
}

return title
},
Expand Down

0 comments on commit 9c91b75

Please sign in to comment.