Problem/Motivation

I upgraded my website from 10.1.7 to 10.2.0 and i got a visual error on administration
Broken keywords field

Steps to reproduce

1. Creates a content type with a referenced field (taxonomy) with an allowed number of values set to "Unlimted" or at least "2"
2. Upgrade your website to Drupal 10.2.0
3. Try to create a content
4. You should see exactly the same issue as me (Drag and drop with the order field and the "Show row weights" button is missing)

Proposed resolution

Simply change the colspan value from 2 to 3

Expected result

Expected visual of keywords field

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

bakop created an issue. See original summary.

bakop’s picture

Issue summary: View changes
StatusFileSize
new12.98 KB

bakop changed the visibility of the branch 3410535-the-visual-of to hidden.

bakop changed the visibility of the branch 3410535-the-visual-of to active.

bakop’s picture

Assigned: bakop » Unassigned
Status: Active » Needs review

Patch sent as merge request (MR!9) !
It works only for version >=10.2.0 so a new release should be published.

ahmad khader’s picture

I can confirm this issue, this is causing tabledrag.js to not work properly and is throwing an Uncaught TypeError: Cannot read properties of undefined (reading 'colSpan')

It's caused by the core adding a remove button on a separate column.

@bakop, we could change the PR to follow the normal core behavior by adding an empty th tag. ([],)

    $header = [
      [
        'data' => [
          '#prefix' => '<h4' . $header_attributes . '>',
          '#markup' => $element['#title'],
          '#suffix' => '</h4>',
        ],
        'colspan' => 2,
        'class' => ['field-label'],
      ],
      [],
      t('Order', [], ['context' => 'Sort order']),
    ]; 

What do you think?

markdorison’s picture

Status: Needs review » Needs work

I just left a comment with an idea on how to not drop support for versions < 10.2 and there is a different idea presented in #7. Marking this as needs work so we can see what else we can come up with.

bakop’s picture

Assigned: Unassigned » bakop
Status: Needs work » Active
bakop’s picture

Assigned: bakop » Unassigned
Status: Active » Needs review

Hello, you are both right. I modified and tested the code on versions 10.1.7 and 10.2.1

ahmad khader’s picture

thanks @bakop
I can also confirm that the code worked on 10.2.1.

markdorison’s picture

I pushed a revision that I believe should accomplish the same thing, but without duplicating the entire $header array. There may be a more elegant way to do this but this was my best idea so far. Could you test to ensure this approach resolves the issue?

sandeep_k’s picture

StatusFileSize
new77.22 KB
new80.87 KB

I've Tested this on a freshly installed Drupal version- 10.2.2-dev & able to reproduce this issue there as well. After reproducing this I've applied the shared patch MR !9 mergeable successfully and it looks good to me.

Testing Steps:

  1. Set up a Drupal 10.2
  2. Enable/Install the Require on Publish module
  3. Creates a content type with a referenced field (taxonomy) Select 'Required on Publish' with an allowed number of values set to "Unlimted" or at least "2"
  4. Create a node> for the newly created content type.
  5. Scroll down to the referenced field (taxonomy)- Shared before result.
  6. Download the shared patch & apply.
  7. Go to> Newly created content type> Scroll down to the referenced field (taxonomy) and re-verify this.

Testing Results:
After applying the patch, the "Show row weights" button is present now. RTBC+

stborchert’s picture

Status: Needs review » Reviewed & tested by the community

Thanks for the patch. We stumbled across this issue after updating to Drupal 10.2 and all paragraph forms were broken.
Without the patch you'll get the following javascript error:
Cannot read properties of undefined (reading 'colSpan')

  • markdorison committed 9890a5e4 on 8.x-1.x authored by bakop
    Issue #3410535 by bakop, markdorison, Sandeep_k, Ahmad Khader,...
markdorison’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.