fix: scroll to reply anchor on forum topic page
Some checks are pending
NordaBiz Tests / Unit & Integration Tests (push) Waiting to run
NordaBiz Tests / E2E Tests (Playwright) (push) Blocked by required conditions
NordaBiz Tests / Smoke Tests (Production) (push) Blocked by required conditions
NordaBiz Tests / Send Failure Notification (push) Blocked by required conditions

When opening a forum topic from a notification link (e.g. #reply-55),
the page now smoothly scrolls to the specific reply with a brief
highlight, accounting for the sticky header offset.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Maciej Pienczyn 2026-04-09 21:53:31 +02:00
parent f0bdfe013b
commit 150af432bf

View File

@ -1503,6 +1503,25 @@
{% endblock %}
{% block extra_js %}
// Scroll to reply anchor (e.g. from notification link #reply-55)
(function() {
var hash = window.location.hash;
if (hash && hash.startsWith('#reply-')) {
var target = document.getElementById(hash.substring(1));
if (target) {
var headerH = document.querySelector('header');
var offset = headerH ? headerH.offsetHeight + 16 : 80;
setTimeout(function() {
var top = target.getBoundingClientRect().top + window.pageYOffset - offset;
window.scrollTo({ top: top, behavior: 'smooth' });
target.style.transition = 'box-shadow 0.3s ease';
target.style.boxShadow = '0 0 0 3px var(--primary-light, #4a6999)';
setTimeout(function() { target.style.boxShadow = ''; }, 3000);
}, 200);
}
}
})();
function showToast(message, type = 'info', duration = 4000) {
const container = document.getElementById('toastContainer');
const icons = { success: '✓', error: '✕', warning: '⚠', info: '' };