From f53e1339ba38ff162f94e4755ba95b0475b1d2ef Mon Sep 17 00:00:00 2001 From: abrahammordev Date: Tue, 24 Mar 2026 12:47:19 +0100 Subject: [PATCH 1/2] Fix (Accessibility) : Implement button element to close selected file --- .../Component/Input/Field/Renderer.php | 4 +- .../Component/Input/Field/FileInputTest.php | 84 ++++++++++--------- 2 files changed, 46 insertions(+), 42 deletions(-) diff --git a/components/ILIAS/UI/src/Implementation/Component/Input/Field/Renderer.php b/components/ILIAS/UI/src/Implementation/Component/Input/Field/Renderer.php index eb592d872722..73a13df1e3d0 100755 --- a/components/ILIAS/UI/src/Implementation/Component/Input/Field/Renderer.php +++ b/components/ILIAS/UI/src/Implementation/Component/Input/Field/Renderer.php @@ -919,7 +919,9 @@ protected function renderFilePreview( ): Template { $template->setCurrentBlock('block_file_preview'); $template->setVariable('REMOVAL_GLYPH', $default_renderer->render( - $this->getUIFactory()->symbol()->glyph()->close()->withAction("#") + $this->getUIFactory()->button()->shy('', '#') + ->withSymbol($this->getUIFactory()->symbol()->glyph()->close()) + ->withAriaLabel('close') )); if (null !== $file_info) { diff --git a/components/ILIAS/UI/tests/Component/Input/Field/FileInputTest.php b/components/ILIAS/UI/tests/Component/Input/Field/FileInputTest.php index ca31d8d3e960..1935450e3bd4 100755 --- a/components/ILIAS/UI/tests/Component/Input/Field/FileInputTest.php +++ b/components/ILIAS/UI/tests/Component/Input/Field/FileInputTest.php @@ -157,10 +157,11 @@ public function testRender(): void
-
@@ -169,7 +170,7 @@ class="ui-input-file-input-error-msg" data-dz-error-msg>
- +
file_notice 0 B | ui_file_upload_max_nr 1
@@ -177,7 +178,7 @@ class="ui-input-file-input-error-msg" data-dz-error-msg> ', $byline, null, - 'id_3' + 'id_4' ); $this->assertEquals($expected, $this->render($file_input)); } @@ -224,14 +225,14 @@ public function testRenderValue(): void test file name 1 1 KB - - - +
@@ -241,10 +242,11 @@ public function testRenderValue(): void
-
@@ -253,7 +255,7 @@ class="ui-input-file-input-error-msg" data-dz-error-msg>
- +
file_notice 0 B | ui_file_upload_max_nr 1
@@ -261,7 +263,7 @@ class="ui-input-file-input-error-msg" data-dz-error-msg>
', null, null, - 'id_4' + 'id_6' ); $this->assertEquals($expected, $this->render($file_input)); } @@ -305,20 +307,20 @@ public function testRenderWithMetadata(): void - - - +
@@ -333,16 +335,15 @@ class="glyphicon glyphicon-triangle-right" tabindex="0" class="glyph" href="#" aria-label="collapse_content">
@@ -351,7 +352,7 @@ class="c-field-text" />
- +
file_notice 0 B | ui_file_upload_max_nr 1
@@ -359,7 +360,7 @@ class="c-field-text" /> ', null, null, - 'id_6', + 'id_8', ); $this->assertEquals($expected, $this->render($file_input)); } @@ -412,20 +413,20 @@ public function testRenderWithMetadataValue(): void test file name 1 1 MB - - - +
@@ -447,15 +448,16 @@ public function testRenderWithMetadataValue(): void
@@ -464,7 +466,7 @@ class="c-field-text" />
- +
file_notice 0 B | ui_file_upload_max_nr 1
@@ -472,7 +474,7 @@ class="c-field-text" /> ', null, null, - 'id_6' + 'id_8' ); $this->assertEquals($expected, $this->render($file_input)); } From d9e04d18302ba605262cecff8960ba3e5abf3205 Mon Sep 17 00:00:00 2001 From: abrahammordev Date: Tue, 24 Mar 2026 14:55:35 +0100 Subject: [PATCH 2/2] fix: Update close button HTML generation in FileInputTest --- .../Component/Input/Field/FileInputTest.php | 66 ++++++++++--------- 1 file changed, 36 insertions(+), 30 deletions(-) diff --git a/components/ILIAS/UI/tests/Component/Input/Field/FileInputTest.php b/components/ILIAS/UI/tests/Component/Input/Field/FileInputTest.php index 1935450e3bd4..396596201df7 100755 --- a/components/ILIAS/UI/tests/Component/Input/Field/FileInputTest.php +++ b/components/ILIAS/UI/tests/Component/Input/Field/FileInputTest.php @@ -71,6 +71,19 @@ protected function brutallyTrimHTML(string $html): string return parent::brutallyTrimHTML($html); } + private function getCloseButtonHtml(string $id): string + { + $html = $this->brutallyTrimHTML( + $this->getDefaultRenderer()->render( + $this->getUIFactory()->button()->shy('', '#') + ->withSymbol($this->getUIFactory()->symbol()->glyph()->close()) + ->withAriaLabel('close') + ) + ); + + return str_replace('id="id_1"', 'id="' . $id . '"', $html); + } + private function getUploadHandler(?FileInfoResult $file = null): Field\UploadHandler { return new class ($file) implements Field\UploadHandler { @@ -146,20 +159,19 @@ public function testRender(): void $label = "label"; $byline = "byline"; $file_input = $f->file($this->getUploadHandler(), $label, $byline)->withNameFrom($this->name_source); + $close_button = $this->getCloseButtonHtml('id_1'); $expected = $this->getFormWrappedHtml( 'file-field-input', $label, - ' + <<