dom-ref

command
v4.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 5, 2026 License: MIT Imports: 2 Imported by: 0

README

DOM Ref + Focus-on-Mount

Attaches a real DOM ref to an input and focuses it on mount — then unmounts it to prove the ref detaches cleanly. No getElementById, no autofocus attribute.

What it shows

  • ui.UseDOMRef() + shorthand.Ref(ref) to capture the live element during the commit phase.
  • ui.UseAutoFocus(ref, when) to focus the referenced element whenever it is (re)shown — on first mount and each time it is revealed.
  • The ref releasing its element on unmount (toggle it off and back on), so no stale node is held.

Run

gwc dev examples/public/dom-ref

Toggle the input off and on; it re-focuses on each reveal.

Documentation

Rendered for js/wasm

Overview

Command dom-ref is the runnable e2e fixture for the G2 DOM-ref primitive (ui.UseDOMRef + shorthand.Ref). It focuses an input via the ref on mount, and can unmount it to prove the ref detaches — exercised by the playwright e2e.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL