Add tooltip to truncated bookmark titles (#607)

* Add title to link so you can see the entire title when hover

* Tweak JS, styles

* Fix snapshot tests

---------

Co-authored-by: Sascha Ißbrücker <sascha.issbruecker@gmail.com>
This commit is contained in:
Jonathan Sundqvist
2024-01-27 10:16:44 +01:00
committed by GitHub
parent 935189ecc2
commit 81ae55bc1c
4 changed files with 44 additions and 3 deletions

View File

@@ -59,10 +59,18 @@ class BookmarkItem {
constructor(element) {
this.element = element;
// Toggle notes
const notesToggle = element.querySelector(".toggle-notes");
if (notesToggle) {
notesToggle.addEventListener("click", this.onToggleNotes.bind(this));
}
// Add tooltip to title if it is truncated
const titleAnchor = element.querySelector(".title > a");
const titleSpan = titleAnchor.querySelector("span");
if (titleSpan.offsetWidth > titleAnchor.offsetWidth) {
titleAnchor.dataset.tooltip = titleSpan.textContent;
}
}
onToggleNotes(event) {