Focus [autofocus] on navigation and frame load #169
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Focus autofocus on navigation and frame load
According to the
<input>
element's documentation for the[autofocus]
attribute:Focus the Snapshot that is connected to the DOM
During the rendering process, the
PageRenderer
replaces the currentSnapshot
with the contents of the newSnapshot
, while theFrameRenderer
extracts the contents of the new Snapshot and uses it toreplace the contents of the current
Snapshot
.Instead of accepting a
Snapshot
as an argument,Renderer.focusFirstAutofocusableElement()
uses whicheverSnapshot
isconnected to the current document.
Co-authored-by: Javan Makhmali javan@basecamp.com
Test coverage to preserve turbo-frame attributes
Add test coverage for preserving turbo-frame attributes during render,
making sure that any element state is preserved while the contents are
modified.
Skip autofocus during previews
Pass the
isPreview
value to theView.renderPage()
call, and thenrestore the guard clause removed by a7d02f0.