You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Within my edit function I modify the attribute with onChange={ ( value ) => setAttribute( { metaAttribute: value } )
In my save function I get the attribute as usual with const { ..., metaAttribute } = attributes;
Problem: If I reopen / reload the post at the backend metaAttribute is initially undefined. That leads to either a "whitescreen"-error with length of undefined because, well, the attribute itself is undefined or a blockvalidation-error if I handle it with a default value.
Just a moment later the save function is triggered again and console.log( metaAttribute ) got the correct value. But that doesn't help with the problem since blockvalidation is triggered before the attribute is read from post meta.
To Reproduce
Steps to reproduce the behavior:
Have an attribute from meta
setAttribute within edit function
use the metaattribute within save
Expected behavior
No errors ¯_(ツ)_/¯
The attribute should be the saved value and not undefined on "init"
Screenshots
Desktop (please complete the following information):
all
Smartphone (please complete the following information):
all
Additional context
This issue might be duplicated, see: #4989
If so please let me now so I'll follow the other issue instead.
The text was updated successfully, but these errors were encountered:
Thanks for the report. I do think this a duplicate of #4989, but the other issue could have done better to explain more detail to how the bug occurs. I've tried to elaborate on this point at #4989 (comment).
Describe the bug
I have a metavalue with key
mymetakey
.My blockattributes:
Within my
edit
function I modify the attribute withonChange={ ( value ) => setAttribute( { metaAttribute: value } )
In my
save
function I get the attribute as usual withconst { ..., metaAttribute } = attributes;
Problem: If I reopen / reload the post at the backend
metaAttribute
is initiallyundefined
. That leads to either a "whitescreen"-error withlength of undefined
because, well, the attribute itself is undefined or a blockvalidation-error if I handle it with a default value.Just a moment later the
save
function is triggered again and console.log( metaAttribute ) got the correct value. But that doesn't help with the problem since blockvalidation is triggered before the attribute is read from post meta.To Reproduce
Steps to reproduce the behavior:
Expected behavior
No errors ¯_(ツ)_/¯
The attribute should be the saved value and not
undefined
on "init"Screenshots
Desktop (please complete the following information):
all
Smartphone (please complete the following information):
all
Additional context
This issue might be duplicated, see: #4989
If so please let me now so I'll follow the other issue instead.
The text was updated successfully, but these errors were encountered: