Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Image Block: Enable image block to be selected correctly when clicked #56043
Image Block: Enable image block to be selected correctly when clicked #56043
Changes from 3 commits
8c0dd62
63cc630
348e110
f2a8b6a
6818f46
e9ea459
746099d
8a37216
5936361
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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 fixes the issue that @jeryj reported for me.
Seems to be acceptable according to the spec, but I'll defer to other folks.
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.
@t-hamano No, you can't add
tabindex="-1"
like this. Doing that prevents the link from gaining focus with arrow key navigation. You need to be able to focus if you are going to hear things like the URL, ALT text, filename, etc.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.
In the context of the editor, the link is a very recent addition whose only function is to ensure the editor styles match the frontend because some global styles target A-tags. The A-tag doesn't actually need an href value to achieve this.
Would it be acceptable to remove it from the accessibility tree or mark it as presentation only or something?
Were the ALT text and filename not available from the IMG element previously?
If getting these attributes is preferable and, bear with me as this might be wild 😄, could we add a data-href to the surrounding figure, which is the selectable "block" element?
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.
@ramonjd You can't add
role="presentation"
to the link or else you will also destroy the semantics of the<img>
tag wrapped inside. I never actually knew you could link an image block so not sure how it worked before. Pretty sure if there is no link, you could not access that information because<img>
by default cannot take focus. That is a bug that needs to be fixed somehow.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 very difficult problem, but for this PR, it might be better to focus on the problem of not being able to click the linked Image block correctly. That is, don't add code like
tabIndex=-1
that prevents thea
element in the block from being focused.It is not only the Image block that the keyboard focuses on the
a
element within the block. For example, a similar problem occurs with the Site Logo block with the home link set.I think we can discuss more broadly in another issue, such as what kind of keyboard interaction is expected in the editor and what should be communicated to screen readers when the block contains an
a
element or animg
element. .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.
Agreed. If you use your arrow keys to select the block and the
<a>
becomes focussed, you can always focus the block wrapper with left arrow. This is how all blocks with wrappers work withtabindex="0"
set on the wrapper.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.
Ah okay, I appreciate the explanation @alexstine Thank you! 👍🏻
Sounds like a good approach.
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.
👍🏻