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
PLANET-6874: Fix the Gallery block #932
Conversation
/unhold 3707dcf7-85b7-44db-be6e-b9113701847e
Test instance is ready 🚀🌑 nix | admin | blocks report | CircleCI | composer-local.json ⌚ 2023.03.15 10:52:27 |
/unhold a36cbd2d-2d09-4f53-80bf-e847df65cd5d
c30e13b
to
8c46dcc
Compare
/unhold a1f42112-1776-47fc-ac69-6c3402bf2a23
/unhold e5ebe159-d312-4754-9bc4-6e449d3eeb3d
onClick={() => { | ||
onImageClick(index); | ||
}} | ||
data-index={index} |
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.
@@ -125,9 +125,8 @@ export const GalleryCarousel = ({ images, onImageClick, isEditing }) => { | |||
style={{ objectPosition: image.focus_image }} | |||
alt={image.alt_text} | |||
title={image.alt_text} | |||
onClick={() => { |
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 is basically a performance tuning, since this lambda function is created every time the render
method is invoked for the only reason to send the index
value.
className, | ||
gallery_block_style, | ||
images, | ||
attributes, |
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.
Because we hydrate
the component.
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.
Maybe we could set {}
as default value here? Then we would avoid later on having to check attributes && attributes.gallery_block_title
for example 🤔
classes/blocks/class-gallery.php
Outdated
@@ -53,7 +53,7 @@ public function register_gallery_block() { | |||
'render_callback' => static function ( $attributes ) { | |||
$attributes['images'] = self::get_images( $attributes ); | |||
|
|||
return self::render_frontend( $attributes ); | |||
return self::hydrate_frontend( $attributes ); |
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.
We need to create a similar render_frontend
method because when you hydrate
a component you need to pass the data-hydrate
instead of a data-render
attribute. After we hydrate
all render
components we'll need to remove this method too.
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.
Would this affect how we implemented hydration for the Carousel Header? Maybe not in this PR, but we could open a follow-up ticket to investigate that
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.
We would need to check that, good suggestion :)
/unhold 3c6ba4c6-d71c-43b7-8784-e90bba8f4218
/unhold d8846611-0177-4391-8cc5-f60691bcfdd5
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.
Did you test the changes with existing blocks? On local I get the Attempt block recovery
message in the editor and in the frontend the block no longer shows...
Edit: on the test instance, it seems that existing blocks still show on the frontend, but in the backend I do see the error message
635d364
to
1e289a6
Compare
1e289a6
to
b478237
Compare
/unhold db51f8bd-c387-4d46-a6c8-0d559b82f2e5
I still see both of these issues 😕 |
/unhold 4a86ad40-767e-4959-9c64-895b4c2edf10
1bb65b2
to
f93c68c
Compare
/unhold 6a7200b4-4f8b-4e77-b03c-3a5d3c034e80
- Implement hydrate_frontend render callback function - Make improvements to the gallery class, update attrs
- Pass new CSR attribute if it's needed - Update documentation
- Modify openLightbox method passing the event instead an index
- Hydrate the component and deprecate againts the frontendRendered - Implement new component version - Implement validations
f93c68c
to
a71244a
Compare
/unhold ac010092-106b-49ad-9037-40ff67e0cb29
045b681
to
b2fd6e7
Compare
/unhold 02d4c4ba-a359-42d7-91ab-132f594057ec
b2fd6e7
to
7742a5a
Compare
/unhold 8ea2e162-0a2e-4557-bb09-59619fece015
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.
Looks good to me, great job! 👏 I've left 2 suggestions in the comments, but they're not blockers 🙂
- Modify variables assignements - Update the deprecated attribute - Fix the 'Warning: Expected server HTML to contain a matching <section> in <div>' issue - Fix evt prevent default issue
7742a5a
to
dad5c6e
Compare
/unhold 6cbfac0a-7c9c-4d35-8b71-032f81f1b0a6
/unhold e014cca4-acd2-4c80-bb71-916a3cdb2156
Ref: https://jira.greenpeace.org/browse/PLANET-6874
Description
Major changes
hydrate
the component because it was using a deprecated method when saved it. Now it's a fully SSR Component.slider
.In addition to this, I've also left a bunch of comments on this PR explaining the reason of most of the new changes.
👉 Demo page