Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WritingFlow in navigation mode doesn't scroll the page #22420

Closed
afercia opened this issue May 18, 2020 · 3 comments
Closed

WritingFlow in navigation mode doesn't scroll the page #22420

afercia opened this issue May 18, 2020 · 3 comments
Labels
[Feature] Writing Flow Block selection, navigation, splitting, merging, deletion... [Focus] Accessibility (a11y) Changes that impact accessibility and need corresponding review (e.g. markup changes).

Comments

@afercia
Copy link
Contributor

afercia commented May 18, 2020

Describe the bug

When the editor is switched to "navigation mode", the WritingFlow component is supposed to make the Tab and Down / Up arrow keys navigate from block to block.

Actually, the blocks are selected but the page doesn't scroll. In a page with long content, this defeats the whole purpose of WritingFlow as the selected block doesn't ever come into view.

To reproduce
Steps to reproduce the behavior:

  • edit a post with some long content
  • click on the title
  • use the Tab or Down arrow keys to move to the first block after the title
  • press Escape to switch to "navigation mode"
  • keep pressing the Tab or Down arrow keys to navigate the blocks
  • observe the page doesn't scroll
  • observe the Sidebar: the content changes and shows the selected blocks type and settings, which is correct and proves the blocks are actually selected
  • however the page doesn't scroll so keyboard users can't really see which block is selected

Note that in this context, the term "selected" refers to the Gutenberg block selection mechanism, not the DOM selection methods.

Animated GIF to better illustrate:

writing flow navigation mode

In the scenario above, I wonder how this block navigation mechanism is of any help for sighted keyboard users.

Expected behavior
The page to scroll and the "selected" block to be into the screen view.

Browsers details

  • note: I can see some scrolling only with Safari stable 13.1
  • no page scroll with Safari technology preview Release 106 (Safari 13.2, WebKit 15610.1.12.2)
  • no page scroll with macOS Chrome 81
  • no page scroll with macOS Firefox 76.0.1

Editor version (please complete the following information):

  • WordPress version: 5.4 and trunk
  • can reproduce on the WP 5.4 block editor, the trunk block editor, and the plugin Version 8.1.0

Additional context
Code responsible for this behavior:

// In navigation mode, tab and arrows navigate from block to block.
if ( isNavigationMode ) {
const navigateUp = ( isTab && isShift ) || isUp;
const navigateDown = ( isTab && ! isShift ) || isDown;
const focusedBlockUid = navigateUp
? selectionBeforeEndClientId
: selectionAfterEndClientId;
if ( navigateDown || navigateUp ) {
if ( focusedBlockUid ) {
event.preventDefault();
selectBlock( focusedBlockUid );
} else if ( isTab && selectedBlockClientId ) {
const wrapper = getBlockDOMNode( selectedBlockClientId );
let nextTabbable;
if ( navigateDown ) {
nextTabbable = focus.tabbable.findNext( wrapper );
} else {
nextTabbable = focus.tabbable.findPrevious( wrapper );
}
if ( nextTabbable ) {
event.preventDefault();
nextTabbable.focus();
clearSelectedBlock();
}
}
}
return;
}

@afercia afercia added [Focus] Accessibility (a11y) Changes that impact accessibility and need corresponding review (e.g. markup changes). [Feature] Writing Flow Block selection, navigation, splitting, merging, deletion... labels May 18, 2020
@aduth
Copy link
Member

aduth commented May 18, 2020

Is there something of the "code responsible" (e.g. event.preventDefault) you're expecting would be preventing the scroll behavior from taking place?

I observe that outside navigation mode, there's a "scroll into view" behavior in caret selection placement of placeCaretAtVerticalEdge (source). If I recall, a custom implementation was used for multi-selection (MultiSelectScrollIntoView), likely at least in part because "multi-selection" is largely an emulated selection.

Unsure if it's a case where something like this is necessary for navigation mode, or if the default focus behavior could be expected to bring the focused block into view.

@afercia
Copy link
Contributor Author

afercia commented May 18, 2020

I tried to comment out event.preventDefault() as first thing, and didn't notice changes in the behavior.

FYI: just created another issue which highlights more WritingFlow buggy behaviors that happen only with Firefox, see #22424

The fact it works (sort of) in Safari 13.1 and there are additional broken behaviors in Firefox potentially highlights some non-standard method used to move focus or maybe an issue related to timings or who-knows-what that makes the actual behavior very inconsistent across browsers.

@tellthemachines
Copy link
Contributor

I tested this in Chrome and Safari on macOS and Chrome and Firefox on Windows 11 and it's working well now. Closing this issue; feel free to reopen if it reoccurs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Writing Flow Block selection, navigation, splitting, merging, deletion... [Focus] Accessibility (a11y) Changes that impact accessibility and need corresponding review (e.g. markup changes).
Projects
None yet
Development

No branches or pull requests

3 participants