Skip to content

PostViewLink Component breaks on undefined labels #62918

Closed

Description

@JNBG

Description

When editing some Template Files via the Website-Editor the Page died with a JS-Error Message in the console that the component could not access "view_item" on labels.

Happend when accessing a Template like the header. The Page is using a custom built theme/editor Plugin so the Error is probably caused by that (using the 2024-Theme it did not occur).

Even tho the Issue is caused by custom Coding, the Checks for undefined could/should be in Place.

Issue Report in Slack (with some Infos from @Automattic)

Step-by-step reproduction instructions

  1. Open Website-Editor
  2. Go To Tempalte-Parts
  3. Click on Header
  4. Site crashes with Error in Console

Screenshots, screen recording, code snippet

Can be fixed by by changing the Line 16280 in editor.js from
label: postType?.labels.view_item
to
label: postType?.labels?.view_item
(added the ? to check if labels is defined).

Other occurence on Line 13819 in editor.js in the "PostURL" Component might be experiencing the same Issue - According to Info from Slack, this could be just removed.

Environment info

WP 6.5.5
Desktop with Windows 10
Chrome Version 126.0.6478.127
Custom built WP Theme (non-official)
Custom built WP Editor (non-official)

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, No

Activity

  1. added
    [Type] BugAn existing feature does not function as intended
    on Jun 27, 2024
  2. JNBG commented on Jun 27, 2024

    @JNBG
    Author

    Some further Digging revealed it appears that it is the "wp_template_part" PostType causing the Issues, this one is missing Labels, supports etc.
    Found it later as it broke the PostTypeSupportCheck Component next

  3. JNBG commented on Jun 27, 2024

    @JNBG
    Author

    Further info on the PostTypeSupportCheck Component:
    It broke due to the "wp_template_part" Posttype not having a supports Key. (editor.js:7248) -> Wrapped that in an if statement to circumvent the Issue for now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

[Block] Template PartAffects the Template Parts Block[Feature] UI ComponentsImpacts or related to the UI component system[Status] In ProgressTracking issues with work in progress[Type] BugAn existing feature does not function as intended

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions