-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Site Editor: Add template check to 'setPage' action. #38656
Conversation
Size Change: +8 B (0%) Total Size: 1.14 MB
ℹ️ View Unchanged
|
coreStore, | ||
'__experimentalGetTemplateForLink', | ||
page.path | ||
); | ||
|
||
if ( ! template ) { | ||
return; |
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.
Should there be any kind of visible error for users if there's no template?
If so, perhaps a notice can be dispatched.
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.
The editor will display a notice if the template doesn't exist:
gutenberg/packages/edit-site/src/components/editor/index.js
Lines 253 to 267 in 9543b72
{ templateResolved && | |
! template && | |
settings?.siteUrl && | |
entityId && ( | |
<Notice | |
status="warning" | |
isDismissible={ | |
false | |
} | |
> | |
{ __( | |
"You attempted to edit an item that doesn't exist. Perhaps it was deleted?" | |
) } | |
</Notice> | |
) } |
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.
Great, in that case I've approved the PR.
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.
LGTM 🎉
Thanks for the review, @talldan. |
I was just going to create an issue for this as I had an odd behaviour while adding template parts to a classic theme. I basically only had a
@Mamaduka It seems that I'll get the "You attempted to edit an item that doesn't exist. Perhaps it was deleted?" message now? Do you think I should create another issue since I'm kind of expecting that it loads the Some quick steps to reproduce:
|
Hi, @ocean90 A separate issue would be great 🙇 I think fixing this error just surfaced other problems with template resolution. |
Description
The
__experimentalGetTemplateForLink
selector can returnnull
when there's no template. PR adds check to avoid errors during destructuring.gutenberg/packages/core-data/src/selectors.js
Lines 880 to 895 in fe8707b
Types of changes
Bugfix
Checklist:
*.native.js
files for terms that need renaming or removal).