Skip to content

Node.js based forum software built for the modern web

fix: hide unread anchor properly when close to bottom

Barış Soner Uşaklı457f6cf3855f
diff --git a/public/src/modules/navigator.js b/public/src/modules/navigator.js
index 766bc02d9c..a10c26055b 100644
--- a/public/src/modules/navigator.js
+++ b/public/src/modules/navigator.js
@@ -377,6 +377,10 @@ define('navigator', [
function toggleAnchor(text) {
anchorEl.innerText = text;
+ anchorEl.style.display = text ? 'inline' : 'none';
+ if (text) {
+ translator.translate(text).then(translated => anchorEl.innerText = translated);
+ }
anchorEl.setAttribute('aria-disabled', text ? 'false' : 'true');
if (text) {
anchorEl.removeAttribute('tabindex');
@@ -384,11 +388,11 @@ define('navigator', [
anchorEl.setAttribute('tabindex', -1);
}
}
+ const anchorHeight = anchorEl.getBoundingClientRect().height;
- if (remaining > 0 && (trackHeight - thumbBottom) >= thumbHeight) {
- const text = await translator.translate(`[[topic:navigator.unread, ${remaining}]]`);
+ if (remaining > 0 && (trackHeight - thumbBottom) >= Math.min(16, anchorHeight)) {
anchorEl.href = `${config.relative_path}/topic/${ajaxify.data.slug}/${Math.min(index + 1, ajaxify.data.postcount)}`;
- toggleAnchor(text);
+ toggleAnchor(`[[topic:navigator.unread, ${remaining}]]`);
} else {
anchorEl.href = ajaxify.data.url;
toggleAnchor('');