diff --git a/client.js b/client.js index 3b6977c..e2bd362 100644 --- a/client.js +++ b/client.js @@ -3120,6 +3120,36 @@ try { return 'all'; } + function navigateCategorySeamless(targetUrl, key) { + if (!targetUrl) return; + + try { + var isAll = (key === 'all' || targetUrl === '/videos/browse' || targetUrl === '/'); + var intermediateUrl = isAll ? '/videos/browse?all=true' : targetUrl; + + // SPA transition via HTML5 History + Angular popstate + history.pushState(null, '', intermediateUrl); + window.dispatchEvent(new PopStateEvent('popstate', { state: null })); + + if (isAll) { + // Clean up the URL to /videos/browse after Angular processes the change + setTimeout(function () { + try { + history.replaceState(null, '', '/videos/browse'); + } catch (e) {} + }, 350); + } + + // Schedule unified engine cycle to ensure DOM consistency + if (typeof scheduleUnifiedCycle === 'function') { + scheduleUnifiedCycle(true); + } + } catch (err) { + console.warn('[YakTube] Seamless navigation fallback:', err); + window.location.href = targetUrl; + } + } + function injectCategoryChipsBar() { var path = (window.location.pathname || '').toLowerCase(); if ( @@ -3232,14 +3262,30 @@ try { } chip.addEventListener('click', function (e) { - if (cat.key === activeKey) { - e.preventDefault(); - return; - } + e.preventDefault(); + if (cat.key === getActiveCategoryKey()) return; + announce(cat.label + ' kategorisi seçildi.'); + + // Immediate visual and ARIA active state update + var allChips = track.querySelectorAll('.yaktube-category-chip'); + allChips.forEach(function (c) { + var isCurrent = (c === chip); + c.classList.toggle('active', isCurrent); + c.setAttribute('aria-selected', isCurrent ? 'true' : 'false'); + c.setAttribute('tabindex', isCurrent ? '0' : '-1'); + }); + + // Seamless SPA navigation without page reload (v1.6.1) + navigateCategorySeamless(cat.url, cat.key); }); chip.addEventListener('keydown', function (e) { + if (e.key === ' ' || e.key === 'Spacebar') { + e.preventDefault(); + chip.click(); + return; + } if (e.key === 'ArrowRight' || e.key === 'ArrowDown') { e.preventDefault(); var next = chip.nextElementSibling; diff --git a/package.json b/package.json index 5e66751..de54cc8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "peertube-plugin-yaktube-ondemand", - "version": "1.6.0", + "version": "1.6.1", "description": "Accessible On-Demand YouTube Import, Live Streams, Smart Recommendations, Sleep Timer, Touch Gestures, Voice Assistant & A11y Engine for PeerTube", "main": "main.js", "library": "./main.js",