Skip to content

A URL fragment cannot name a part of a widget, and navigateToDatum writes only the widget id #4993

Closed

Description

@max-sixty

A URL can't name a part of a widget. Threads and navigateToDatum reach a widget's parts through its keys, but fragmentTarget reads only element ids. navigateToDatum also writes the widget's own id into the URL, so reloading or sharing the URL after it lands at the top of the widget, not on the part.

I ran into this while writing a widget that draws one item at a time and fetches each item when it's picked. I wanted a copy-link control on each part of an item, and there was no URL for it to copy.

What happens

Take a widget <x-items id="items"> whose module answers keys such as b/3, meaning part 3 of item b:

  • lfRevealDatum("b/3") picks item b, draws it, and returns a promise that resolves once it's drawn.
  • lfElementsFor("b/3") returns the drawn part.

Then:

  1. Another widget that refers to items through x-refers calls navigateToDatum(this, "for", "b/3"). Leaf picks b, lands on part 3 and focuses it. The URL now ends in #items.
  2. Reloading that URL lands at the top of items, on whichever item it draws first.
  3. No fragment names part 3 of item b, so a copy-link control on the part has nothing to copy, and a reply can't link to the part.

The parts can't carry element ids of their own. They aren't in the page until their item is picked, and every item's parts use the same ids.

Expected

One fragment spelling for a widget id plus a key, resolved by the step anchor-resolution.js already shares between threads and navigateToDatum: revealAddressed, then addressedElements. The comment on revealAddressed says every travel to a part of a widget asks it, "so neither route reaches a part the other cannot". The URL is the one route that doesn't.

A possible shape:

  • The fragment resolves to an element id first, as now. Otherwise it's read as a widget id and a key, and resolves to the widget, so the code that only needs the element lands on the widget as it does today.
  • followFragment, returnToFragment and the fresh-load landing then reveal the key and land on the part. At load, the reveal's promise could count as a deferredArrival, which the landing already waits for.
  • navigateToDatum writes that spelling instead of the widget's id, so its URL reloads and shares to the same part.
  • The widget API builds the URL for a widget and a key, so a module's copy-link control doesn't spell the format itself. The check that a reply's fragment link is live accepts the same form.

A widget that already answers lfRevealDatum or lfElementsFor would then get links to its parts with no new hook.

Seen on leaf b88915a, installed 2026-11-01T10:36:05-08:00.

This was written by Claude Code on behalf of max-sixty

Activity

  1. added
    enhancement
    on Nov 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions