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

Impossible to make the formatting toolbar appear after Escape has been pressed #5501

Closed
afercia opened this issue Mar 8, 2018 · 3 comments · Fixed by #5551
Closed

Impossible to make the formatting toolbar appear after Escape has been pressed #5501

afercia opened this issue Mar 8, 2018 · 3 comments · Fixed by #5551
Labels
[Focus] Accessibility (a11y) Changes that impact accessibility and need corresponding review (e.g. markup changes). [Type] Bug An existing feature does not function as intended

Comments

@afercia
Copy link
Contributor

afercia commented Mar 8, 2018

To reproduce, use only the keyboard:

Navigate to a block and select some text: the formatting toolbar appears

screen shot 2018-03-08 at 13 07 10

Shift + Tab to go to the toolbar and apply some formatting:

screen shot 2018-03-08 at 13 07 15

Press Escape: the toolbar correctly disappears and focus is on the block again:

screen shot 2018-03-08 at 13 07 26

Use the arrow keys to move the cursor to some other text and Shift + arrow to select some text (same if you select the previous text):

screen shot 2018-03-08 at 13 07 33

The formatting toolbar doesn't appear. The only way I've found to "fix" this is to tab away from teh block and then tab back into it.

Expected: when there's a text selection, the formatting toolbar should always appear.

Suspect: pressing Escape propagates to the block and the block is no more "selected" (notice in the screenshot above the block movers and more button are not shown).

@afercia afercia added [Type] Bug An existing feature does not function as intended [Focus] Accessibility (a11y) Changes that impact accessibility and need corresponding review (e.g. markup changes). labels Mar 8, 2018
@afercia
Copy link
Contributor Author

afercia commented Mar 8, 2018

Note: this happens even without going to the toolbar to apply some formatting. Just:

  • select some text
  • press Escape
  • select again some text: the toolbar doesn't appear

@aduth
Copy link
Member

aduth commented Mar 9, 2018

This should be somewhat improved after #5513.

Specifically the notes on pressing escape in a block:

Pressing escape in a block should do nothing

  • Arguable whether this is the desired behavior, but it is consistent with native inputs. Master is in a worse state because the block becomes deselected but the text caret is not removed, causing issues because the block never again becomes selected (because isSelected is synced to its focus event, but focus has never left).

Pressing escape in the toolbar has slightly different behavior, because we're annoyingly handling escape keys in many places in many different ways.

The NavigableToolbar is shifting focus to the selected block:

onToolbarKeyDown( event ) {
if ( event.keyCode !== ESCAPE ) {
return;
}
// Is there a better way to focus the selected block
// TODO: separate focused/selected block state and use Redux actions instead
const selectedBlock = document.querySelector( '.editor-block-list__block.is-selected' );
if ( !! selectedBlock ) {
event.stopPropagation();
selectedBlock.focus();
}
}

Even though EditorGlobalKeyboardShortcuts is simultaneously clearing the selected block:

escape: this.props.clearSelectedBlock,

So the paragraph block border shows, but the block is not technically selected. Pressing tab once more returns to the selection which existed prior to the escape press (and the block is once again selected).

Maybe intended / desirable, not sure. It all seems rather convoluted and fragile though in its current form.

@afercia
Copy link
Contributor Author

afercia commented Mar 10, 2018

I'd agree it's a bit fragile right now and maybe needs some rethinking.

Pressing Escape in the toolbar should just return focus to the edited block still in a "selected" state, as I'm still editing the block.

Re: #5513

Pressing escape in a block should do nothing

Worth considering the pending experiment about "navigation mode / edit mode", see #3195 and #2031. If implemented, then pressing Escape in a block should switch back to "navigation mode."

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Focus] Accessibility (a11y) Changes that impact accessibility and need corresponding review (e.g. markup changes). [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants