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
- Open the form containing the rows and columns table.
- Delete columns until only one column remains.
- Notice that the Delete column button is still displayed.
- Delete rows until only one row remains.
- 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}
| Comment | File | Size | Author |
|---|---|---|---|
| #8 | After patch.PNG | 79.33 KB | anjuelsaphilip2020 |
| #8 | Before patch.PNG | 85.83 KB | anjuelsaphilip2020 |
| #7 | charts-hide_delete_row_delete_column_buttons-3619247-7.patch | 2.15 KB | dench0 |
Issue fork charts-3619247
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
Comment #2
dench0Comment #3
dench0Comment #5
dench0Comment #6
dench0Comment #7
dench0Comment #8
anjuelsaphilip2020 commentedHi, 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:
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.
Comment #10
andileco commentedThanks for your contributions!