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

Anchor Tags In Gallery Images Are Covered by the Caption, Rendering Them Unclickable #14304

Closed
Steve-MP opened this issue Mar 7, 2019 · 14 comments
Assignees
Labels
[Block] Gallery Affects the Gallery Block - used to display groups of images [Focus] Accessibility (a11y) Changes that impact accessibility and need corresponding review (e.g. markup changes). [Status] In Progress Tracking issues with work in progress [Type] Bug An existing feature does not function as intended
Milestone

Comments

@Steve-MP
Copy link

Steve-MP commented Mar 7, 2019

Describe the bug
The Gutenberg Gallery block renders each image with the caption overlaid over the image. This is done by absolute positioning of the figcaption element. Because the caption is not rendered inside the anchor tag which links each image to its source file, the area covered by the caption is not clickable. This is unexpected behaviour from a user perspective and provides a bad experience. Users expect the whole image/caption block to be clickable. Because the figcaption is rendered with a transparent backdrop, it is not clear to the user why the clickable area of the image seems to arbitrarily end half way down the image.

To Reproduce
Steps to reproduce the behavior:

  1. Create a post
  2. Insert a Gutenberg Gallery block
  3. Add an image with a long caption and select Link To: Media File from the block menu to the right of the editor interface
  4. Save the post
  5. Visit the post page
  6. Attempt to click the image at various places - note that the clickable area ends at an arbitrary point.

Expected behavior
The whole image should be clickable, even if a caption is present. If there is a caption, the caption should be included in the anchor tag.

Screenshots
clicky

Desktop (please complete the following information):

  • OS: OSX Mojave
  • Google Chrome for Mac v. 72.0.3626.121

Additional context

  • The version in Wordpress core 5.1
@youknowriad
Copy link
Contributor

Should we wrap the caption inside the link cc @jasmussen @mapk ?

@jasmussen
Copy link
Contributor

Can we add pointer-events: none; to the caption? I don't know if we can add the caption inside the link, as captions can be multiline (i.e. they are wrapped in P) and a p nested inside an a tag is invalid HTML.

@Steve-MP
Copy link
Author

Steve-MP commented Mar 7, 2019

Can we add pointer-events: none; to the caption? I don't know if we can add the caption inside the link, as captions can be multiline (i.e. they are wrapped in P) and a p nested inside an a tag is invalid HTML.

I think that in HTML5 you can wrap an anchor around pretty much anything apart from other interactive elements. Wrapping block level elements like p inside an a is fine.

@mapk
Copy link
Contributor

mapk commented Mar 11, 2019

I think that in HTML5 you can wrap an anchor around pretty much anything apart from other interactive elements.

Let's move in this direction. Are there any a11y issues that we should anticipate regarding this change?

@noisysocks noisysocks added [Type] Bug An existing feature does not function as intended [Block] Gallery Affects the Gallery Block - used to display groups of images Needs Accessibility Feedback Need input from accessibility labels Mar 13, 2019
@noisysocks noisysocks added this to the WordPress 5.x milestone Mar 13, 2019
@oandregal
Copy link
Member

Related #13164

@mapk mapk added the Needs Dev Ready for, and needs developer efforts label Apr 4, 2019
@ashwin-pc
Copy link
Contributor

Hey! I saw the Needs Dev label. I'd love to take this issue up.

@gziolo gziolo removed the Needs Dev Ready for, and needs developer efforts label Apr 10, 2019
@afercia
Copy link
Contributor

afercia commented Apr 10, 2019

Before looking at the PR, I'd like to point out this problem already existed in the pre-Gutenberg era. However, it actually depended on the theme.

For example, some of the bundled themes render the classic gallery captions in a way that doesn't overlay the image, see Twenty Seventeen:

gallery twenty seventeen

Instead, other bundled themes do overlay the caption onto the image e.g. Twenty Fourteen (same for Twenty Thirteen):

gallery twenty fourteen

So this problem is not new to Gutenberg and it's actually a design issue.

Worth also noting the classic gallery in Twenty Nineteen doesn't overlay the captions:

classic gallery twenty nineteen

While the Gutenberg gallery does overlay captions:

gutenberg gallery twenty nineteen

So on one hand, Gutenberg makes an opinionated choice and forces the captions to overlay the image. On the other hand, it doesn't provide a solution to the clickable area issue.

I'm not sure forcing this rendering is the best option. To me, this should be handled by the theme and should be a theme author's choice.

Will post accessibility related considerations on the PR.

@afercia afercia added [Focus] Accessibility (a11y) Changes that impact accessibility and need corresponding review (e.g. markup changes). and removed Needs Accessibility Feedback Need input from accessibility labels Apr 10, 2019
@mapk
Copy link
Contributor

mapk commented Apr 10, 2019

@ashwin-pc thanks for jumping into this! 👍

@mapk
Copy link
Contributor

mapk commented Apr 10, 2019

I'm not sure forcing this rendering is the best option. To me, this should be handled by the theme and should be a theme author's choice.

Good point @afercia. I wonder if the two different styles can be block style variations as mentioned in this comment.

@afercia
Copy link
Contributor

afercia commented Apr 11, 2019

@maok yep commented also on #11436. I'd totally second your point: style variations could really make sense here.

@gziolo
Copy link
Member

gziolo commented May 17, 2019

@ashwin-pc did some explorations in #11436 which was concluded with the following recommendation:

does the caption need to stay visible when the image is hovered? -> consider to hide it, or truncate it, or reduce its height on hover (or any other "smart" behavior)
Can we try this? Hide the caption on hover if the caption covers the image.

It was also noted by @mapk that this isn't a perfect solution but it's fine to fix the bug:

I'm willing to take this tradeoff because I believe clicking an image to view it at a larger scale is the prefered action here. This PR can work toward this, and in the future we can create a PR that adds another style variation where the captions are below the images.

@github-actions github-actions bot added the [Status] In Progress Tracking issues with work in progress label Apr 29, 2022
@glendaviesnz
Copy link
Contributor

Can we add pointer-events: none; to the caption? I don't know if we can add the caption inside the link, as captions can be multiline (i.e. they are wrapped in P) and a p nested inside an a tag is invalid HTML

This approach seems to work with the new innerBlocks Gallery @jasmussen - PR here.

@ndiego
Copy link
Member

ndiego commented Jun 29, 2022

@glendaviesnz there was some conversation about this issue in the Editor Weekly Bug Scrub, here is the direct link to the conversation. The consensus after reading through all the comments on this issue and the associated closed PRs, is that this is expected behavior and the issue should be closed. While I personally agree that WordPress Core likely should not have added the caption overlay to begin with since captions can also have links, this issue can be "resolved" with an additional block style or through specific theme styles. The block style approach would be an enhancement PR in my mind.

So, what are your thoughts on closing this issue?

@glendaviesnz
Copy link
Contributor

@ndiego I agree with that conclusion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Gallery Affects the Gallery Block - used to display groups of images [Focus] Accessibility (a11y) Changes that impact accessibility and need corresponding review (e.g. markup changes). [Status] In Progress Tracking issues with work in progress [Type] Bug An existing feature does not function as intended
Projects
No open projects