diff --git a/CHANGELOG.md b/CHANGELOG.md index 29e2f87..c6ccdec 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,8 +7,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## [Unreleased] -### Fixed +### Fixed +- Fixed the `Table` question's columns configuration panel forcing the whole page to scroll instead of scrolling on its own - Fix Table question column type edge cases ## [1.3.0] - 2026-08-11 diff --git a/templates/editor/question_types/table_config.html.twig b/templates/editor/question_types/table_config.html.twig index af9bb0c..d53a701 100644 --- a/templates/editor/question_types/table_config.html.twig +++ b/templates/editor/question_types/table_config.html.twig @@ -69,6 +69,7 @@
diff --git a/tests/Model/QuestionType/TableQuestionAdminConfigRenderingTest.php b/tests/Model/QuestionType/TableQuestionAdminConfigRenderingTest.php new file mode 100644 index 0000000..e588663 --- /dev/null +++ b/tests/Model/QuestionType/TableQuestionAdminConfigRenderingTest.php @@ -0,0 +1,125 @@ +type = new TableQuestion(); + $this->login(); + } + + public function testColumnsContainerScrollsOnItsOwnInsteadOfThePage(): void + { + $html = $this->renderConfig([ + $this->column('A', QuestionTypeShortText::class), + $this->column('B', QuestionTypeShortText::class), + ]); + + $crawler = new Crawler($html); + $container = $crawler->filter('[data-af-table-columns-container]')->first(); + + $this->assertGreaterThan( + 0, + $container->count(), + 'The columns configuration panel must be present in the rendered admin template.', + ); + + $style = (string) $container->attr('style'); + $this->assertStringContainsString( + 'overflow-y: auto', + $style, + 'The columns container must scroll on its own once it has enough columns, ' . + 'instead of forcing the whole page (and the still-open dropdown menu with it) to scroll.', + ); + $this->assertMatchesRegularExpression( + '/max-height\s*:\s*\d+(\.\d+)?(vh|px|rem|em)/', + $style, + 'A bare `overflow-y: auto` with no height constraint never actually scrolls.', + ); + } + + /** + * @param array $columns + */ + private function renderConfig(array $columns): string + { + $this->enableConfigurableItem($this->type); + + $builder = new FormBuilder('Admin config rendering form'); + $builder->addQuestion( + 'Table', + TableQuestion::class, + extra_data: json_encode(new TableQuestionConfig(columns: $columns)), + ); + $form = $this->createForm($builder); + + $question = Question::getById($this->getQuestionId($form, 'Table')); + + return $this->type->renderAdvancedConfigurationTemplate($question); + } + + /** + * @return array{name: string, question_type: string, required: bool, itemtype: string, pattern: string} + */ + private function column(string $name, string $fqcn): array + { + return [ + TableQuestionConfig::COL_NAME => $name, + TableQuestionConfig::COL_QUESTION_TYPE => $fqcn, + TableQuestionConfig::COL_REQUIRED => false, + TableQuestionConfig::COL_ITEMTYPE => '', + TableQuestionConfig::COL_PATTERN => '', + ]; + } +}