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

Image block: lightbox trigger misplaced depending on contextual layout #66958

Open
2 of 6 tasks
afercia opened this issue Nov 13, 2024 · 6 comments · May be fixed by #67042
Open
2 of 6 tasks

Image block: lightbox trigger misplaced depending on contextual layout #66958

afercia opened this issue Nov 13, 2024 · 6 comments · May be fixed by #67042
Assignees
Labels
[Block] Image Affects the Image Block [Status] In Progress Tracking issues with work in progress [Type] Bug An existing feature does not function as intended

Comments

@afercia
Copy link
Contributor

afercia commented Nov 13, 2024

Description

When an image opens the lightbox, a 'trigger' icon button is displayed on hover or focus on the front end. It appears this button absolute positioning top and right value are calculated based on a series of factors but, in some cases, the actual positioning might end to be less than ideal.

In the case of a normal Image block, the positioning works pretty well. However, when the Image block has a non-default layout due to being inside other containers, the positioning is really inconsistent and unpredictable. I would say it's not a great experience for users.

For example, in the screenshot below I'm using a Group block with its 'Grid' variation and I placed six images inside the grid. For some images, the placement of the button is less than ideal:

Image

I don't have enough context to understand why the button position needs to be calculated. Given it's absolutely positioned based on the container figure element, wouldn't be better to drastically simplify and provide fixed top and right values?

Worth noting this misplacement may happen with any particular layoug, not only with the Group grid.

Noting that the misplacement of this button makes it even more difficult to be clearly visible. See related #55513

Step-by-step reproduction instructions

  • Add a Group block set to a Grid variant.
  • Add six images with different size ratio and with or without captions inside the grid.
  • Save and view the front end.
  • Hover or focus the images.
  • Observe the placement of the trigger button is inconsistend and unpredictable.

Screenshots, screen recording, code snippet

No response

Environment info

No response

Please confirm that you have searched existing issues in the repo.

  • Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

  • Yes

Please confirm which theme type you used for testing.

  • Block
  • Classic
  • Hybrid (e.g. classic with theme.json)
  • Not sure
@afercia afercia added [Block] Image Affects the Image Block [Feature] Interactivity API API to add frontend interactivity to blocks. [Type] Bug An existing feature does not function as intended labels Nov 13, 2024
@michalczaplinski
Copy link
Contributor

I'm gonna remove the [Feature] Interactivity API label. While the lightbox uses the Interactivity API, this seems to be a CSS / layout problem that is unrelated to the API itself.

@michalczaplinski michalczaplinski removed the [Feature] Interactivity API API to add frontend interactivity to blocks. label Nov 13, 2024
@afercia
Copy link
Contributor Author

afercia commented Nov 14, 2024

@michalczaplinski to my understanding the calculation of the button position is in the view.js. I thought that was part of the Interactivity API implementation. What would be the most appropriate label to indicate this is anyways related to the Interactivity?

@michalczaplinski
Copy link
Contributor

Oh, I didn't realize we calculated the button's position in JS. In that case, it IS related, sorry!

We use the label for issues in the API itself, and its usage in Core blocks, so it makes sense to re-add it 🙂 .

@michalczaplinski michalczaplinski added the [Feature] Interactivity API API to add frontend interactivity to blocks. label Nov 15, 2024
@afercia
Copy link
Contributor Author

afercia commented Nov 15, 2024

Thanks @michalczaplinski 👍🏻

@luisherranz
Copy link
Member

@artemiomorales can you take a look?

@Takshil-Kunadia
Copy link
Contributor

The logic for calculating the top-offset for the button is not robust, neither is necessary. Since, its absolutely positioned like @afercia mentioned. It can have a static top offset of 16px and that takes care of that. Though calculation is needed for the position from the right, as small images combined with large captions, skew the position of the button to be outside the image.

@Takshil-Kunadia Takshil-Kunadia linked a pull request Nov 15, 2024 that will close this issue
@github-actions github-actions bot added the [Status] In Progress Tracking issues with work in progress label Nov 15, 2024
@luisherranz luisherranz removed the [Feature] Interactivity API API to add frontend interactivity to blocks. label Nov 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Image Affects the Image Block [Status] In Progress Tracking issues with work in progress [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants