gutenberg icon indicating copy to clipboard operation
gutenberg copied to clipboard

Regression bugs when post type template_lock = 'contentOnly'

Open bvlgn opened this issue 3 years ago • 5 comments

Description

With Gutenberg 15.1.1 active when the template_lock of a post type template is set to 'contentOnly', the expected behaviour is no longer as it was with WP 6.1.1. with the Gutenberg plugin deactivated. The content lock functionality is broken.

Step-by-step reproduction instructions

See code sample. Add it to your theme functions.php Add a new Book and try to edit the content of the paragraphs, e.g:

  • if you click on a paragraph block the group is always selected (the child should be selected)
  • if you click in the inspector in the content panel on a child paragraph the cursor is placed in the block but you cannot reposition the cursor
  • if you click in the inspector in the content panel on a child paragraph the regular inspector panels show (they shouldn't)
  • you can move the child block (shouldn't be possible)

Screenshots, screen recording, code snippet

<?php
function register_books_post_type() {
  $labels = array(
    'name' => __( 'Books', 'text-domain' ),
    'singular_name' => __( 'Book', 'text-domain' ),
    'menu_name' => __( 'Books', 'text-domain' ),
  );

  $args = array(
    'labels' => $labels,
    'public' => true,
    'publicly_queryable' => true,
    'show_ui' => true,
    'show_in_menu' => true,
    'show_in_rest' => true,
    'query_var' => true,
    'rewrite' => array( 'slug' => 'books' ),
    'capability_type' => 'post',
    'has_archive' => true,
    'hierarchical' => false,
    'menu_position' => null,
    'supports' => array( 'title', 'editor', 'thumbnail' ),
    'template' => array(
      array(
        'core/group',
        array(),
        array(
          array(
            'core/paragraph',
            array(
              'placeholder' => 'Book Description - Paragraph 1',
              'content' => 'This is the first paragraph of the book description. 1',
            )
          ),
          array(
            'core/paragraph',
            array(
              'placeholder' => 'Book Description - Paragraph 2',
              'content' => 'This is the second paragraph of the book description.',
            )
          ),
        )
      ),
    ),
    'template_lock' => 'contentOnly',
  );

  register_post_type( 'books', $args );
}

add_action( 'init', 'register_books_post_type' );

Environment info

Wordpress 6.1.1 with Gutenberg 15.1.1. active

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

bvlgn avatar Feb 21 '23 18:02 bvlgn

@BennyVL Thanks for the report.

I will investigate this issue in the near future, but I have formatted the code in your comment once so that more people can test this issue.

t-hamano avatar Feb 22 '23 05:02 t-hamano

if you click on a paragraph block the group is always selected (the child should be selected) if you click in the inspector in the content panel on a child paragraph the cursor is placed in the block but you cannot reposition the cursor if you click in the inspector in the content panel on a child paragraph the regular inspector panels show (they shouldn't) you can move the child block (shouldn't be possible)

I was able to reproduce this problem with WordPress 6.2-beta3-55402. It occurs both when the Gutenberg plugin is enabled and when it is disabled.

https://user-images.githubusercontent.com/54422211/220641538-afaea290-fe33-4a7c-af9a-bea8ef31eead.mp4


WordPress 6.1.1 shows the expected UI as follows

6 1 1_group

6 1 1_paragraph

t-hamano avatar Feb 22 '23 14:02 t-hamano

@Mamaduka fyi

ndiego avatar Feb 22 '23 15:02 ndiego

@kevin940726 could you perhaps dig in here since you've done so much around exploring content lock for patterns?

annezazu avatar Feb 22 '23 19:02 annezazu

I'm not sure TBH! This looks like it's about template's contentOnly but not group's contentOnly. I can try looking into it, but maybe someone else with more knowledge over that area would figure it out faster than me 😅 .

kevin940726 avatar Feb 23 '23 11:02 kevin940726