Problem/Motivation

The icon for the local tasks is not showing even tho there is an icon in the assets folder.

Steps to reproduce

  • Install module and add the local tasks block
  • See the icon is not showing

Proposed resolution

Add the icon.

Remaining tasks

Create and review MR.

User interface changes

Icon will be shown in the navigation.

API changes

None.

Data model changes

None.

Command icon 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

tim-diels created an issue. See original summary.

tim-diels’s picture

Status: Active » Needs review
tim-diels’s picture

I had another view on this and it would be awesome to actually let the user choose an icon and fall back to a default when no icon is selected. I adjusted the code.

dtfabio’s picture

Assigned: Unassigned » dtfabio
dtfabio’s picture

Hi Tim,

I tested the code change on three different Drupal instances.

Drupal core versions: 10.3.14, 10.6.3 and 11.3.3
PHP versions: 8.3.30 (10.3) and 8.4.18 for the newer core versions.
Database version: MariaDB 11.8.6

After adding the patch, I received the following error on all three (when UI icons module is not enabled on the site):

Warning: Undefined array key "icon" in Drupal\navigation_extra\Plugin\Block\NavigationExtraLocalTasksBlock->build() (line 164 of /var/www/html/web/modules/contrib/navigation_extra/src/Plugin/Block/NavigationExtraLocalTasksBlock.php)

Because my configuration does not contain a key "icon" (dump via xdebug):

array (
  'id' => 'navigation_extra_local_tasks',
  'label' => 'Local Tasks',
  'label_display' => 'visible',
  'provider' => 'navigation_extra',
  'primary' => 1,
  'secondary' => 1,
  'context_mapping' => 
  array (
  ),
)

After removing and re-adding the block with UI Icons module enabled, I get the following configuration:

array (
  'id' => 'navigation_extra_local_tasks',
  'label' => 'Local Tasks',
  'label_display' => 'visible',
  'provider' => 'navigation_extra',
  'primary' => 1,
  'secondary' => 1,
  'context_mapping' => 
  array (
  ),
  'icon' => NULL,
)

The problem does reappear after disabling the UI Icons module and adding the block again, so I think that around the icons part in the build, there will likely also needs to be a check to see if the module is enabled before the configuration is retrieved.

I will test choosing an icon now, but wanted to pass on this information already.

Greetings,

Fabio

dtfabio’s picture

Assigned: dtfabio » Unassigned
Status: Needs review » Needs work
StatusFileSize
new376.87 KB

Hi Tim,

I have tested selecting an icon and this works well. The only comment I have is that the icons in the autocomplete selection list sometimes take up a lot of space.

I think it might be useful to specify a fixed size here so that the icons are always displayed in the same way.

Icons show very large in autocomplete list.

Also noticed that even on a site where UI Icons was already enabled, the error I mentioned earlier occurs, given that the block already existed before the patch was added. So I don't know if my previously mentioned fix will cover the entire load.

Greetings,

Fabio

tim-diels’s picture

Assigned: Unassigned » tim-diels

I'll look into this.

tim-diels’s picture

Assigned: tim-diels » Unassigned
Status: Needs work » Needs review

The icon_autocomplete is not something that is done by this module. It is a good find, but we have no impact on this.
I adjusted what is needed here. So can you please retest?

dtfabio’s picture

Assigned: Unassigned » dtfabio
dtfabio’s picture

Assigned: dtfabio » Unassigned
Status: Needs review » Needs work

Hi Tim,

After retesting the adjustments, the array errors are gone, but I still get the following error on the Drupal 10 site:

Error: Call to undefined method Drupal\navigation_extra\Plugin\Block\NavigationExtraLocalTasksBlock::traitSubmitConfigurationForm() in Drupal\navigation_extra\Plugin\Block\NavigationExtraLocalTasksBlock->submitConfigurationForm() (line 111 of /var/www/html/web/modules/contrib/navigation_extra/src/Plugin/Block/NavigationExtraLocalTasksBlock.php).

Allowing icon selection means that the code will not be compatible with both 10.x and 11.x. So perhaps you could split the functionality and, for now, just include the icon and we can create a follow-up issue to allow icon selection?

Greetings,

Fabio

dtfabio’s picture

tim-diels’s picture

Status: Needs work » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

  • tim-diels committed 149b7baa on 1.0.x
    fix: #3575239 Icon for local tasks not showing
    
    By: tim-diels
    By:...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.