Changeset 1c6d61c in Klonkt


Ignore:
Timestamp:
06/20/2026 08:19:11 AM (3 months ago)
Author:
roboburr <roboburr@…>
Branches:
main
Children:
cf0de0c
Parents:
4dcefa1
Message:

fix(nav): Timeline/Grid active state via aria-selected (htmx-robust)

Root cause: body-attribute CSS (body[data-feed-view]) does NOT react reliably
after an htmx OOB swap; element attributes do. Therefore the active Timeline/Grid
state is now via [aria-selected="true"] (set by syncAria, which fires on
htmx:afterSettle) instead of body[data-feed-view]. syncAria sets aria-selected
only on feed pages → on calendar/downloads/post both are grey. Template also
sets the initial aria-selected neutral on non-feed pages.

Co-Authored-By: Claude <noreply@…>

Location:
src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • src/assets/css/style.css

    r4dcefa1 r1c6d61c  
    21332133   Niet op de Archive-pagina: daar is geen "huidige" timeline/grid-keuze, dus beide
    21342134   knoppen blijven neutraal (grijs). */
    2135 body[data-feed-view="timeline"]:not(.on-archive):not(.on-shows):not(.on-downloads) .view-switch-btn[data-view="timeline"],
    2136 body[data-feed-view="grid"]:not(.on-archive):not(.on-shows):not(.on-downloads) .view-switch-btn[data-view="grid"] {
    2137     background: var(--ink);
    2138     color: var(--paper);
    2139     border-color: var(--ink);
    2140 }
     2135/* Actieve Tijdlijn/Grid-state wordt nu gestuurd via [aria-selected="true"] (gezet
     2136   door syncAria, die óók op htmx:afterSettle draait) i.p.v. body[data-feed-view].
     2137   Reden: body-class/attribuut-CSS pakte niet betrouwbaar na een htmx-OOB-swap;
     2138   een element-attribuut wel. De witte active-regel staat in shared-styles. */
    21412139.view-switch-btn .icon { width: 1rem; height: 1rem; }
    21422140
  • src/views/partials/shared-styles.ejs

    r4dcefa1 r1c6d61c  
    3636}
    3737.view-switch-btn:hover { color: var(--ink); }
    38 .view-switch-btn[aria-selected="true"] { background: var(--paper); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.06); }
     38/* Actief = wit (lichte achtergrond, donkere tekst). Via aria-selected (element-
     39   attribuut, door syncAria gezet + op htmx:afterSettle) → htmx-robuust. Op niet-
     40   feed-pagina's zet syncAria aria-selected=false → beide grijs. */
     41.view-switch-btn[aria-selected="true"] { background: var(--ink); color: var(--paper); border-color: var(--ink); }
    3942
    4043/* Agenda = een EIGEN pill (los van Tijdlijn/Grid, zodat de feed-toggle nooit
  • src/views/partials/view-switcher.ejs

    r4dcefa1 r1c6d61c  
    3636    <div class="view-switcher" role="tablist" aria-label="Weergave">
    3737      <button type="button" class="view-switch-btn" data-view="timeline" role="tab"
    38               aria-selected="<%= (typeof site !== 'undefined' && site && site.feed_view_default === 'grid') ? 'false' : 'true' %>">
     38              aria-selected="<%= (!_neutral && !(typeof site !== 'undefined' && site && site.feed_view_default === 'grid')) ? 'true' : 'false' %>">
    3939        <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><line x1="8" y1="6" x2="21" y2="6"/><line x1="8" y1="12" x2="21" y2="12"/><line x1="8" y1="18" x2="21" y2="18"/><line x1="3" y1="6" x2="3.01" y2="6"/><line x1="3" y1="12" x2="3.01" y2="12"/><line x1="3" y1="18" x2="3.01" y2="18"/></svg>
    4040        <span>Tijdlijn</span>
    4141      </button>
    4242      <button type="button" class="view-switch-btn" data-view="grid" role="tab"
    43               aria-selected="<%= (typeof site !== 'undefined' && site && site.feed_view_default === 'grid') ? 'true' : 'false' %>">
     43              aria-selected="<%= (!_neutral && (typeof site !== 'undefined' && site && site.feed_view_default === 'grid')) ? 'true' : 'false' %>">
    4444        <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect x="3" y="3" width="7" height="7"/><rect x="14" y="3" width="7" height="7"/><rect x="14" y="14" width="7" height="7"/><rect x="3" y="14" width="7" height="7"/></svg>
    4545        <span>Grid</span>
  • src/views/shell.ejs

    r4dcefa1 r1c6d61c  
    384384
    385385  function syncAria() {
     386    // Alleen op een feed-pagina hoort Tijdlijn/Grid 'actief' (wit) te zijn; op
     387    // agenda/downloads/post/etc. beide grijs. Inline feed-check (FEED_PAGE_CLASSES
     388    // staat verderop, maar deze functie draait al bij init).
     389    var _feedC = ['on-home','on-tag','on-type','on-user','on-cirkel'];
     390    var _onFeed = _feedC.some(function(c){ return body.classList.contains(c); });
    386391    document.querySelectorAll('.view-switch-btn').forEach(function(b) {
    387       b.setAttribute('aria-selected', b.dataset.view === body.dataset.feedView ? 'true' : 'false');
     392      b.setAttribute('aria-selected', (_onFeed && b.dataset.view === body.dataset.feedView) ? 'true' : 'false');
    388393    });
    389394    document.querySelectorAll('.grid-cols-btn').forEach(function(b) {
Note: See TracChangeset for help on using the changeset viewer.