Skip to content

Commit ff89305

Browse files
committed
1 parent 3e239d9 commit ff89305

1 file changed

Lines changed: 15 additions & 3 deletions

File tree

assets/js/editor.js

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ const prplGetPageTypeSlugFromId = ( id ) => {
3939

4040
return progressPlannerEditor.pageTypes.find(
4141
( pageTypeItem ) => parseInt( pageTypeItem.id ) === parseInt( id )
42-
).slug;
42+
)?.slug;
4343
};
4444

4545
/**
@@ -48,6 +48,14 @@ const prplGetPageTypeSlugFromId = ( id ) => {
4848
* @return {Element} Element to render.
4949
*/
5050
const PrplRenderPageTypeSelector = () => {
51+
// Bail early if the page types are not set.
52+
if (
53+
! progressPlannerEditor.pageTypes ||
54+
0 === progressPlannerEditor.pageTypes.length
55+
) {
56+
return el( 'div', {}, '' );
57+
}
58+
5159
// Build the page types array, to be used in the dropdown.
5260
const pageTypes = [];
5361
progressPlannerEditor.pageTypes.forEach( ( term ) => {
@@ -187,8 +195,12 @@ const PrplLessonItemsHTML = () => {
187195
}, [] );
188196
const pageTodos = pageTodosMeta || '';
189197

190-
// Bail early if the page type is not set.
191-
if ( ! pageType ) {
198+
// Bail early if the page type or lessons are not set.
199+
if (
200+
! pageType ||
201+
! progressPlannerEditor.lessons ||
202+
0 === progressPlannerEditor.lessons.length
203+
) {
192204
return el( 'div', {}, '' );
193205
}
194206

0 commit comments

Comments
 (0)