-
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
fix: Improve empty block text #11560
Conversation
@@ -245,7 +245,8 @@ class ParagraphBlock extends Component { | |||
onMerge={ mergeBlocks } | |||
onReplace={ this.onReplace } | |||
onRemove={ () => onReplace( [] ) } | |||
placeholder={ placeholder || __( 'Add text or type / to add content' ) } | |||
aria-label={ __( 'Type text or use the forward slash key to insert a block' ) } | |||
placeholder={ placeholder || __( 'Type text or press “/” to select a block' ) } |
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.
It's a super minor nit pick but why can't these labels be identical, with the aria label imply replacing "/"
with "forward slash key" so it's clearer how screen readers should read it?
E.g.
Type text or press the forward slash key to insert a block
and
Type text or press the "/" key to insert a block
It's not clear why the text itself would need to be different in these cases, aside from the visible placeholder showing the slash visually instead of as text.
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.
Works for me actually, good point 👍
<WithSelect(WithDispatch(InserterWithShortcuts)) /> | ||
<WithSelect(IfCondition(Inserter)) | ||
position="top right" | ||
/> |
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.
Anything that might have triggered all these tabs? I guess jest generates spaces by default right?
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 just typed u
after running test-unit:watch
to update the snapshots, so I blame Jest. Should I have run something else?
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.
No, if it's generated by jest this way than maybe the old snapshot was not correct.
@@ -80,7 +80,7 @@ export class PostTextEditor extends Component { | |||
onBlur={ this.stopEditing } | |||
className="editor-post-text-editor" | |||
id={ `post-content-${ instanceId }` } | |||
placeholder={ decodedPlaceholder || __( 'Write your story' ) } | |||
placeholder={ decodedPlaceholder || __( 'Type text or press “/” to insert a block' ) } |
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.
You can't press "/" or insert a block. This is the text editor, you can just type HTML :)
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.
Oh, oops, right. I think it too had the “Write your story” prompt and I just got confused. I’ll update it, my bad! 😅
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.
This will actually still show because we pass the same placeholder to the code editor. We probably shouldn't do that, but it's a different issue...
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.
It's made visible with this PR though, I'd be in favor of dropping the bodyPlaceholder support here.
This is looking good to me, but I prefer to bring people that I know care more than me about "Copy". cc @jasmussen @mtias |
👍 👍 consolidation, 👍 👍 PR. However I prefer the suggestion from the old PR, which was: |
Actually, I agree. Changed! |
@@ -246,7 +246,7 @@ class ParagraphBlock extends Component { | |||
onReplace={ this.onReplace } | |||
onRemove={ () => onReplace( [] ) } | |||
aria-label={ __( 'Empty block; type text or press the forward slash key to insert a block' ) } |
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.
should "type text" be replaced with "start writing"?
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.
For a screen reader I actually think "type text" is better than "start writing".
@@ -71,7 +71,7 @@ export class PostTextEditor extends Component { | |||
return ( | |||
<Fragment> | |||
<label htmlFor={ `post-content-${ instanceId }` } className="screen-reader-text"> | |||
{ decodedPlaceholder || __( 'Write your story' ) } | |||
{ decodedPlaceholder || __( 'Type text' ) } |
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.
Let's remove the decodedPlaceholder
from this component and ship.
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.
Sounds good; if that means this is otherwise good to go mind explicitly reviewing it now? 😄
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.
LGTM 👍
(Looks like there's some failing tests though) |
Shoot, must have run the wrong snapshot update script. Fixed. |
Argh, right, sorry. Okay, I'll file a follow-up PR for this tonight. Thanks so much for that @afercia, my bad. 😓 |
Fix issue introduced in #11560
Thanks for working on this, and apologies for missing this. But right now the text says
The suggestion was:
I defer to any other considerations, but I honestly prefer the initially suggested phrasing. Notaby "press /" feels weird to me, because on a european keyboard this is not a separate key — I have to press Shift + 7 to insert a /. Therefore "type" feels more natural. Additionally, I'm not a fan of the term "insert" for blocks, even though it's accurate. I far prefer "add", or as was suggested "choose a block". The latter implies your caret is already in a block, and you can change the type of it, which is sort of accurate as anything you add replaces the appender block you were in. |
* fix: Only show aria-label when content is empty Fix issue introduced in #11560 * Improve aria labels so they reflect state of block/empty block
Fix #9076
Fix #5591
Consolidate the "Write your story" and "Add text or type" placeholders, while also adding context to the placeholder with an
aria-label
.Screenshots