block.js shouldn't check for select.block-weight because weight elements can be textfields

Created on 18 March 2015, about 9 years ago
Updated 30 January 2023, over 1 year ago

Problem/Motivation

Drupal has a weight form element type. Very useful. Its output is sometimes a select and sometimes a textfield.

That weight element is used on the blocks admin page:

$form['blocks'][$key]['weight'] = array(
  '#type' => 'weight',
  '#default_value' => $block['weight'],
  '#delta' => $weight_delta,
  '#title_display' => 'invisible',
  '#title' => t('Weight for @block block', array('@block' => $block['info'])),
);

so they're not necessarily select elements. block.js doesn't care:

var weightField = $('select.block-weight', dragObject.rowObject.element);

The "select" in the selector is completely redundant, and plain wrong, so the fix couldn't be easier: remove it. Now it works for weight textfields too.

Steps to reproduce

1. $ drush vset drupal_weight_select_max 0
2. Go to the blocks overview admin page.
3. Drag blocks around. You will get JS errors, because the weight element can't be found.

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

πŸ› Bug report
Status

Needs work

Version

9.5

Component
BlockΒ  β†’

Last updated 10 days ago

Created by

πŸ‡³πŸ‡±Netherlands rudiedirkx

Live updates comments and jobs are added and updated live.
  • Needs backport to D7

    After being applied to the 8.x branch, it should be considered for backport to the 7.x branch. Note: This tag should generally remain even after the backport has been written, approved, and committed.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • The Needs Review Queue Bot β†’ tested this issue. It either no longer applies to Drupal core, or fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".

    Apart from a re-roll or rebase, this issue may need more work to address feedback in the issue or MR comments. To progress an issue, incorporate this feedback as part of the process of updating the issue. This helps other contributors to know what is outstanding.

    Consult the Drupal Contributor Guide β†’ to find step-by-step guides for working with issues.

Production build 0.69.0 2024