Problem/Motivation

The form containing the table of row and column text fields allows users to delete rows and columns.

Currently, the Delete row button is still displayed when only one row remains, and the Delete column button is displayed when only one column remains. This allows the user to attempt to delete the last remaining row or column.

The table should always contain at least one row and one column.

Steps to reproduce

  1. Open the form containing the rows and columns table.
  2. Delete columns until only one column remains.
  3. Notice that the Delete column button is still displayed.
  4. Delete rows until only one row remains.
  5. Notice that the Delete row button is still displayed.

Proposed resolution

Do not display the Delete column button when there is only one column remaining.

Similarly, do not display the Delete row button when there is only one row remaining.

This prevents users from attempting to remove the last row or column and ensures that the table always contains at least one row and one column.

It can cause errors with the Paragraphs widget:
TypeError: key(): Argument #1 ($array) must be of type array, false given in key() (line 936 of /var/www/html/web/modules/contrib/charts/src/Element/ChartDataCollectorTable.php).

#0 /var/www/html/web/modules/contrib/charts/src/Element/ChartDataCollectorTable.php(936): key()
#1 /var/www/html/web/modules/contrib/charts/src/Element/Chart.php(350): Drupal\charts\Element\ChartDataCollectorTable::getCategoriesFromCollectedTable()
#2 /var/www/html/web/modules/contrib/charts/src/Element/BaseSettings.php(1544): Drupal\charts\Element\Chart::buildElement()
#3 /var/www/html/web/modules/contrib/charts/src/Element/BaseSettings.php(208): Drupal\charts\Element\BaseSettings::processSeriesForm()
#4 /var/www/html/web/core/lib/Drupal/Core/Form/FormBuilder.php(1065): Drupal\charts\Element\BaseSettings::processSettings()
#5 /var/www/html/web/core/lib/Drupal/Core/Form/FormBuilder.php(1128): Drupal\Core\Form\FormBuilder->doBuildForm()
#6 /var/www/html/web/core/lib/Drupal/Core/Form/FormBuilder.php(1128): Drupal\Core\Form\FormBuilder->doBuildForm()
#7 /var/www/html/web/core/lib/Drupal/Core/Form/FormBuilder.php(1128): Drupal\Core\Form\FormBuilder->doBuildForm()
#8 /var/www/html/web/core/lib/Drupal/Core/Form/FormBuilder.php(1128): Drupal\Core\Form\FormBuilder->doBuildForm()
#9 /var/www/html/web/core/lib/Drupal/Core/Form/FormBuilder.php(1128): Drupal\Core\Form\FormBuilder->doBuildForm()
#10 /var/www/html/web/core/lib/Drupal/Core/Form/FormBuilder.php(1128): Drupal\Core\Form\FormBuilder->doBuildForm()
#11 /var/www/html/web/core/lib/Drupal/Core/Form/FormBuilder.php(1128): Drupal\Core\Form\FormBuilder->doBuildForm()
#12 /var/www/html/web/core/lib/Drupal/Core/Form/FormBuilder.php(1128): Drupal\Core\Form\FormBuilder->doBuildForm()
#13 /var/www/html/web/core/lib/Drupal/Core/Form/FormBuilder.php(470): Drupal\Core\Form\FormBuilder->doBuildForm()
#14 /var/www/html/web/core/lib/Drupal/Core/Form/FormBuilder.php(651): Drupal\Core\Form\FormBuilder->rebuildForm()
#15 /var/www/html/web/core/lib/Drupal/Core/Form/FormBuilder.php(347): Drupal\Core\Form\FormBuilder->processForm()
#16 /var/www/html/web/core/lib/Drupal/Core/Controller/FormController.php(73): Drupal\Core\Form\FormBuilder->buildForm()
#17 [internal function]: Drupal\Core\Controller\FormController->getContentResult()
#18 /var/www/html/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array()
#19 /var/www/html/web/core/lib/Drupal/Core/Render/Renderer.php(634): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#20 [internal function]: Drupal\Core\Render\Renderer::Drupal\Core\Render\{closure}()
#21 /var/www/html/web/core/lib/Drupal/Core/Render/Renderer.php(649): Fiber->resume()
#22 /var/www/html/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(121): Drupal\Core\Render\Renderer->executeInRenderContext()
#23 /var/www/html/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext()
#24 /var/www/html/vendor/symfony/http-kernel/HttpKernel.php(183): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#25 /var/www/html/vendor/symfony/http-kernel/HttpKernel.php(76): Symfony\Component\HttpKernel\HttpKernel->handleRaw()
#26 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/Session.php(53): Symfony\Component\HttpKernel\HttpKernel->handle()
#27 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(48): Drupal\Core\StackMiddleware\Session->handle()
#28 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/ContentLength.php(28): Drupal\Core\StackMiddleware\KernelPreHandle->handle()
#29 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(48): Drupal\Core\StackMiddleware\ContentLength->handle()
#30 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(51): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle()
#31 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/AjaxPageState.php(53): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle()
#32 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/StackedHttpKernel.php(54): Drupal\Core\StackMiddleware\AjaxPageState->handle()
#33 /var/www/html/web/core/lib/Drupal/Core/DrupalKernel.php(745): Drupal\Core\StackMiddleware\StackedHttpKernel->handle()
#34 /var/www/html/web/index.php(19): Drupal\Core\DrupalKernel->handle()
#35 {main}

Issue fork charts-3619247

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

dench0 created an issue. See original summary.

dench0’s picture

Issue summary: View changes
dench0’s picture

Issue summary: View changes

dench0’s picture

dench0’s picture

Status: Active » Needs review
dench0’s picture

StatusFileSize
new2.15 KB
anjuelsaphilip2020’s picture

Status: Needs review » Reviewed & tested by the community
StatusFileSize
new85.83 KB
new79.33 KB

Hi, I've verified and tested the MR!229 and applied the patch successfully on the Charts 5.2.x-dev version. The changes are working as expected.
Following steps I followed:

  1. Go to Content → Add content → Article.
  2. Open the Chart Data section.
  3. Add multiple rows and columns.
  4. Delete rows/columns until only one remains.
  5. Verify the respective Delete button is hidden.
  6. Add a row/column and verify the Delete button reappears..

Testing Result:
After applying the patch, the Delete row and Delete column buttons are hidden when only one row or column remains and reappear when additional rows or columns are added. The changes are working as expected.
Attaching screenshots for reference.
Thanks.

  • d1aca51f committed on 5.2.x
    fix: #3619247 Hide "Delete row" and "Delete column" buttons when only...
andileco’s picture

Status: Reviewed & tested by the community » Fixed

Thanks for your contributions!

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.