~ knotless Search/
↑↓ move↵ open⇧↵ all results

grain.social/grain

photography-focused photo sharing platform

grain.social
1 collaborator
0
2

next: no console warnings as screens are pushed and gone back from

Merged
Merged chadtmiller.com asked to merge into feature/hud from grain.social/grain:next/console

What changes

No derived_inert in the console. A screen's pictures that finish loading after the screen was gone back from no longer make Svelte warn derived_inert. HUD's Picture now listens to its <img>'s load and error events only while it's drawn.

No blocked aria-hidden. The screen under the one on top no longer carries aria-hidden, and neither do a story pager's side pages. Both stay inert, which also keeps them away from the keyboard and from screen readers. A screen opened from a link or button takes focus at its title, and Back returns focus to where it was, the way a native stack navigator does.

No "preloaded but not used". The hero's <link rel="preload"> is now created fresh for each screen in the app. It used to be changed in place, which fetched its href (the full size) before its new srcset said which size to use.

This vendors HUD at 94b9fb9, which is app/shell with this one change on top. Nothing outside vendor/hud changes.

Why

These are the console messages a signed-in Chrome user saw while browsing profiles and galleries on next.grain.social. Each has the following cause.

  • derived_inert: An <img> taken out of the page keeps loading and fires load when it finishes. Picture's handler read its props through Gallery's {...sized}, a {@const} of an each item that went away with the screen. The stack the user saw is the same as the one in a dev build: Gallery.svelte sized → the spread props' get → Picture's onload → target_handler.
  • aria-hidden over focus: When a level is covered, it got aria-hidden while the link the user tapped in it still had focus, so Chrome blocked it. inert alone hides the level from assistive technology. Moving focus into the new screen also means focus is never left in a covered level.
  • preload: Opening a gallery from a profile in the app changed the existing link's href first. Chrome fetched that full size, then fetched the srcset's size once imagesrcset changed, and reported the full size as unused.

How it was checked

  • HUD's npm run check, npm run ssr and npm run unit (37) pass.
    • A new shell test opens a screen of pictures from a focused link, goes back, goes forward (so the screen is fetched again), and goes back again.
    • It fails if focus doesn't move into the screen and back to the link, if the screen under isn't inert alone, or if the late load and error of the screen's pictures warn.
    • Without the change it failed with 16 derived_inert warnings and both focus/aria-hidden checks.
  • node next/check-apps.mjs and next's npm run check pass.
  • In headless Chromium with the accessibility tree on, against vite dev of this next/ with production's HUD (signed out):
    • Before: the open → back → forward → back round gave 4 to 6 derived_inert per gallery and a "Blocked aria-hidden" on a.opens/a.open under section.level.under. Six in-app moves from a fresh cache gave 3 "preloaded but not used" warnings for feed_fullsize URLs.
    • After: the same runs gave none of these warnings. Focus came back to the tapped link.
  • Signed in as alice.test on a local PDS, grain-serve and HUD, a long random walk (stories, sheets, menus, tabs, back and forward) showed none of these warnings either. Pictures don't load locally, so that run couldn't show the picture warning.

Shortcomings

  • The CORS errors come from a browser extension's content_script.js and aren't ours.
  • The "503 (Offline)" for gallery 3mxq2wrysv5n5 is unexplained.
    • Nothing in HUD, next/, Caddy or the containers says "Offline", and there's no service worker.
    • HUD's log has no request for that gallery other than my own curl, so the response never reached our servers. My guess, which I haven't verified, is an extension or a service worker in that browser.
  • A hydration mismatch in the renderer's tree/Stack.svelte showed up once during the local random walk. I didn't follow it up here.

Review

A quick look. Start at HUD's web/shell/src/Stack.svelte, the focus effects.

Approved

This vendors HUD at 94b9fb9. It stops late <img> load and error handlers from running once a Picture is gone. It drops aria-hidden and leaves inert on covered levels and pager side pages. It moves focus into a pushed screen and restores it on Back. It recreates the hero preload <link> per href with {#key}.

I read the diff and found no bugs. I did not run any of it.

  • The drawn flag in Picture works as intended. It is a plain variable that flips only when the component is destroyed, so the handlers never read props after teardown.
  • The focus effects in Stack look right. Focus is saved only if it was inside the stack. Popped levels are dropped from the map, and a disconnected saved element falls back to the title.
  • tabindex="-1" on the level and the h1 is needed for programmatic focus. Check that no focus ring shows on them. That is a visual check, not something I can see in the diff.

On the focus ring: the title and the level take focus only by script, and Chrome's focus-visible heuristic matches a script's focus only where the element focused before matched it. A tap or click on a link (the user's case, and the Chromium runs here) leaves no ring on the title. A keyboard Enter shows the browser's ring on the title, which is where a keyboard user should see focus land, so I left the default styling. I didn't take a screenshot of it.

Merged as 689ffb9
Part of a stack of 2
  1. next: no console warnings as screens are pushed and gone back from Landed as 689ffb9
  2. main