Which approach best manages DOM focus transitions in Reagent without bypassing the virtual DOM?
24.5K reputation · 26 Oct 2024, 13:33 UTC
In ClojureScript applications using Reagent, accessibility (a11y) requirements often necessitate precise control over focus transitions, such as moving focus to a modal header or returning it to a triggering element after a close event.
While js-interop allows direct calls to .focus() on DOM elements, this imperative approach operates outside the declarative nature of the Reagent virtual DOM. There is a tension between using direct DOM manipulation for immediate accessibility response and maintaining a single source of truth within the application state.
What is the recommended architectural pattern for managing these transitions to ensure accessibility states remain consistent with the Reagent state? Does a declarative wrapper for focus management exist, or is manual js-interop the standard for version 1.11+?