Skip to content

Commit

Permalink
Disable aria hidden when a title tag is specified
Browse files Browse the repository at this point in the history
  • Loading branch information
mbardelmeijer committed Dec 3, 2024
1 parent 0db975b commit 100872e
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/Svg.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,10 +153,11 @@ private function renderAttributes()
{
return collect([
'class' => $this->pack->autoSizeOnViewBox ? 'svg-auto-size' : null,
'aria-hidden' => 'true',
'focusable' => 'false',
'role' => 'img',
])
// When no `title` attribute is set, we hide it from screen readers by default.
->when(! $this->attributes->get('title'), fn(Collection $collection) => $collection->put('aria-hidden', 'true'))
->pipe(function (Collection $collection) {
return $collection->merge(
$this->attributes->map(fn ($value, $key) => trim($collection->get($key).' '.$value))
Expand Down

0 comments on commit 100872e

Please sign in to comment.