-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Reveal the Continue Writing controls also on focus #1941
Conversation
There was a problem hiding this 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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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 } |
There was a problem hiding this comment.
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 ) }
>
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...). |
There was a problem hiding this 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.
Sure, thanks! |
Looks good to me, just one small thing: since now the buttons are |
This PR tries to make the "Continue Writing" controls at the bottom of the editor...
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 asbutton Text
andbutton Image
and need to be clarified a bit.Fixes #1939