-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Pattern overrides: Image captions appear to not be handled correctly #62287
Comments
The heart of the problem is that the caption attribute isn't supported by block bindings, and the pattern overrides feature is built upon block bindings. So I've added the 'Block Bindings' label. I agree, it's not ideal, I had really hoped it would be supported for the beta. I'm sure there are still options for solving this though. The first issue is tracked on the iteration - #59819 (edit: I've now updated it to link to this issue). When I tested the other day I thought it had been solved, I'll do some more testing today to establish what's happening. I think the expected behavior you mentioned is an interesting one. If the original pattern creator creates the pattern without a caption, then should the user of the pattern be able to add one? It should match the way the pattern (and by proxy the image) is expected to be used. Similarly, perhaps pattern creators should almost be able to enforce a caption for other types of patterns where one is expected. Edit: Would it be ok to rename the issue to be about image captions? If other issues could be created for other bugs you encounter that would be great. Thanks for testing btw! |
@talldan thanks for your feedback.
Yes, when testing we were wondering about this. I would say captions are specific to a specific image, similarly to the No objections to renaming. It can always be re-renamed, if need be. |
After some more testing: it appears more properties of an image are not overridable>
Not sure a pattern with a linked image can be of any use if the pattern users can't edit the link? |
@afercia the supported attributes are listed in the linked issue:
I don't think there are plans to support more attributes in 6.6. So there needs to be short-term solutions for the unsupported attributes. They should probably be removed when an image is replaced. |
@carolinan found this Draft PR: #61255 @talldan should that be added to the priority list in #59819 ? |
Hadn't seen that one before. Seems like it's missed 6.6 unfortunately, and it'd be a big change during the beta, though potentially parts of it could be merged as bug fixes? Not sure. I feel a little uncomfortable about the use of regexes to replace content in the PR, but we can continuing to look into solutions for this. |
I looked into the reason this happens, and it's due to the way block bindings updates the values for non-bound attributes (in this case, those that aren't supported by pattern overrides). This bit of code: gutenberg/packages/block-editor/src/hooks/use-bindings-attributes.js Lines 216 to 218 in faf5cba
So when you upload an image, it sets a range of attributes, only some of them are supported by bindings/pattern overrides and are updated via the bindings. The unsupported attributes like caption are applied to the block via a normal call to This is something that I don't think should happen for pattern overrides, as the unsupported attributes should never be modifiable from a pattern instance, they can only be edited in the original pattern. The behavior does make sense for other types of block bindings where non-bound attributes can still be edited, so it's a tricky one to solve technically. Perhaps we could say that the presence of the |
I've made a PR that addresses the appearing/dissapearing caption - #62471. I've also had a quick look at what it would take to support image captions for block bindings fully (but no PR yet). I think a first step could be making a similar change to the one we just did for the button block - #62220. There's some client side code that conditionally renders the caption element for the image block: gutenberg/packages/block-library/src/image/save.js Lines 87 to 93 in 2d34e2a
This could be moved to the block's |
Thanks for working on it! I'll take a look and give any feedback there.
Regarding this, I plan to work again on supporting image attributes in this pull request. The original idea was to use something similar to what was done for the button block, although I have to review the logic again. |
Let's try to do this bandaid instead for 6.6: #62747. Adding support for caption seems a bit too late now. |
Description
In a joined testing session with @carolinan and @SergeyBiryukov we wanted to get familiar with and test the Pattern overrides feature unblocked in #62011 and planned to be released in WordPress 6.6.
Our testing was limited to the Image and Paragraph blocks in a pattern so it was a very partial testing with only two blocks. We noticed a few unexpected behaviors especially with the Image block. We are concerned there may be more unexpected behaviors with other blocks at the point we shared the feeling this feature appears to not be fully ready to be released.
I'd like to point out we're not very familiar with the implementation and we tested this feature as 'advanced users'. Users expectations are important though and the general perception we got is that it doesn't feel polished enough to be 'ready'.
Personally, I would argue that content that disappears in an unexpected way or that is not replaced as users would expect doesn't contribute to perceive this feature as reliable and doesn't help users feel confident enough to use it.
Teh reproduction steps are a little complex, I'll try to simplify to only two very evident cases of unexpected behavior.
Step-by-step reproduction instructions
Scenario 1:
Scenario 2:
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
The text was updated successfully, but these errors were encountered: