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..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,21 +159,21 @@ 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, - ' + <<
- +
file_notice 0 B | ui_file_upload_max_nr 1
- ', + HTML, $byline, null, - 'id_3' + 'id_4' ); $this->assertEquals($expected, $this->render($file_input)); } @@ -210,11 +223,13 @@ public function testRenderValue(): void )->withValue([ $test_file_id, ])->withNameFrom($this->name_source); + $close_button = $this->getCloseButtonHtml('id_1'); + $close_button_template = $this->getCloseButtonHtml('id_3'); $expected = $this->getFormWrappedHtml( 'file-field-input', '', - ' + <<
@@ -224,14 +239,12 @@ public function testRenderValue(): void test file name 1 1 KB - - - + {$close_button}
@@ -241,10 +254,9 @@ public function testRenderValue(): void
{$close_button_template}
-
@@ -253,15 +265,15 @@ class="ui-input-file-input-error-msg" data-dz-error-msg>
- +
file_notice 0 B | ui_file_upload_max_nr 1
- ', + HTML, null, null, - 'id_4' + 'id_6' ); $this->assertEquals($expected, $this->render($file_input)); } @@ -283,11 +295,13 @@ public function testRenderWithMetadata(): void "" ] ])->withNameFrom($this->name_source); + $close_button = $this->getCloseButtonHtml('id_1'); + $close_button_template = $this->getCloseButtonHtml('id_4'); $expected = $this->getFormWrappedHtml( 'file-field-input', $label, - ' + <<
@@ -305,20 +319,18 @@ public function testRenderWithMetadata(): void - - - + {$close_button}
@@ -333,16 +345,14 @@ class="glyphicon glyphicon-triangle-right" tabindex="0" class="glyph" href="#" aria-label="collapse_content">{$close_button_template}
@@ -351,15 +361,15 @@ class="c-field-text" />
- +
file_notice 0 B | ui_file_upload_max_nr 1
- ', + HTML, null, null, - 'id_6', + 'id_8', ); $this->assertEquals($expected, $this->render($file_input)); } @@ -389,12 +399,14 @@ public function testRenderWithMetadataValue(): void "test", ] ])->withNameFrom($this->name_source); + $close_button = $this->getCloseButtonHtml('id_1'); + $close_button_template = $this->getCloseButtonHtml('id_4'); $expected = $this->getFormWrappedHtml( 'file-field-input', $label, - ' + <<
@@ -412,20 +424,18 @@ public function testRenderWithMetadataValue(): void test file name 1 1 MB - - - + {$close_button}
@@ -446,16 +456,14 @@ public function testRenderWithMetadataValue(): void - {$close_button_template}
@@ -464,15 +472,15 @@ class="c-field-text" />
- +
file_notice 0 B | ui_file_upload_max_nr 1
- ', + HTML, null, null, - 'id_6' + 'id_8' ); $this->assertEquals($expected, $this->render($file_input)); }