Autocomplete dragtable allows empty values and inserts empty entry

Created on 30 August 2022, almost 2 years ago
Updated 31 May 2024, 28 days ago

Problem/Motivation

When adding an item through the Autocomplete dragtable widget, if user don't fill the textfield it will accept the value and insert an empty record / row on the table, after some debug I have found that there is any check or validation if the user has filled the input or it is empty.
More specifically issue comes from the function addItemAjax() on line 317.

Steps to reproduce

1. Login as admin
2. Navigate to Web -> Structure -> Entity Queue. Click view Subqueues of any available queue
3. Click Edit item.
4. Click Add item without typing anything in the autocomplete field. One empty entry is added.
Attached screenshot for reference.

Proposed resolution

My proposed solution is to add the following code on line 323 to 328.
This will prevent to return on the Ajax responde the array element to be inserted on the 'items-wrapper'.

    // No value inserted on the input or empty value,
    // we don't replace the 'items-wrapper', this
    // will prevent to add empty values.
    if ($element['add_more']['new_item']['target_id']['#value'] === '') {
      return $element;
    }

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Fixed

Version

1.2

Component

Code

Created by

🇪🇸Spain alae.akalay Benalmádena

Live updates comments and jobs are added and updated live.
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.

Production build 0.69.0 2024