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

Reveal the Continue Writing controls also on focus #1941

Merged
merged 5 commits into from
Jul 22, 2017

Conversation

afercia
Copy link
Contributor

@afercia afercia commented Jul 18, 2017

This PR tries to make the "Continue Writing" controls at the bottom of the editor...

text image bottom

revealed also on focus when navigating content with a keyboard.

Also, adds an aria-label to the Text and Image button since they're out of the context of the inserter menu, they're announced by screen readers just as button Text and button Image and need to be clarified a bit.

Fixes #1939

@afercia afercia requested a review from mtias July 18, 2017 18:57
@afercia afercia added the [Focus] Accessibility (a11y) Changes that impact accessibility and need corresponding review (e.g. markup changes). label Jul 18, 2017
Copy link
Member

@aduth aduth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question: Should we be rendering the Text and Image buttons at all when showContinueWritingControls is false? Currently for example when shift-tabbing from "Document" in the Settings sidebar, it focuses Image... but prior to tab the controls weren't visible, so I might have expected the "+" button to be focused instead.

I think we may also want to break out "Continue writing" behavior into its own subcomponent, maybe here or in a subsequent pull request.

className={ continueWritingClassname }
onFocus={ this.onContinueWritingFocus }
onBlur={ this.onContinueWritingBlur }
>
<Inserter position="top right" />
<button
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aside: This should probably just be using the <IconButton /> component.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tried that, and seems the IconButton uses some default focus style that maybe is not appropriate here. Instead, it should maybe use the same focus style of the items in the inserter menu?

screen shot 2017-07-18 at 23 22 55

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could override the outline style in this specific case, or if it's something that would be common, perhaps a prop on IconButton (focusOutline={ false }).

@@ -214,6 +231,9 @@ class VisualEditorBlockList extends Component {
...blocks.slice( insertionPointIndex + 1 ),
]
: blocks;
const continueWritingClassname = classnames( 'editor-visual-editor__continue-writing', {
'show-controls': this.state.showContinueWritingControls,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor: To reduce chance for naming conflicts, might be good to prefix the modifier class with something distinctive for modifiers, like is-showing-controls.

<div className="editor-visual-editor__continue-writing">
<div
className={ continueWritingClassname }
onFocus={ this.onContinueWritingFocus }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor: While it has the downside of not being a shared function reference (bypassing benefit if we ever adopted PureComponent), we could consolidate onFocus and onBlur toggle to a single helper function:

toggleContinueWritingControls( showContinueWritingControls ) {
	return () => this.setState( { showContinueWritingControls } );
}

// ...

<div
	className={ continueWritingClassname }
	onFocus={ this.toggleContinueWritingControls( true ) }
	onBlur={ this.toggleContinueWritingControls( false ) }
>

@afercia
Copy link
Contributor Author

afercia commented Jul 18, 2017

Well if you ask me, I'd make these controls always visible. Not just for a11y reasons but also because I'm not sure revealing UI controls on hover is a good idea in the first place. Hover is going to die (touch devices...).
As it works now, this replicates the behavior of the "row actions" links in the WordPress list tables. Keeping the controls hidden when shift-tabbing maybe would be even more confusing: they would be revealed only when the "+" button gets focus, i.e. when they are already "skipped".
I think it's a safe assumption that users will explore content tabbing forwards first, so they will learn something appears there. And they will probably expect that something appears there also when tabbing backwards.

Copy link
Member

@aduth aduth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I hope you don't mind, but I went ahead and made the IconButton change with style overrides to eliminate the focus box-shadow. Assuming you have no issue with it, this looks good to merge.

@afercia
Copy link
Contributor Author

afercia commented Jul 20, 2017

Sure, thanks!

@afercia
Copy link
Contributor Author

afercia commented Jul 22, 2017

Looks good to me, just one small thing: since now the buttons are IconButtons, the aria-label attribute should be a label prop.

@afercia afercia merged commit b61c82c into master Jul 22, 2017
@afercia afercia deleted the update/continue-writing-controls-reveal-on-focus branch July 22, 2017 10:08
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).
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants