Problem/Motivation
I enabled core modules:
- Toolbar
- Contextual Links
I generated a custom content entity with Drupal Console, added a `my_module.links.contextual.yml` file and added `{{ title_suffix }}` to the entity template.
So far so good. Then, at first page load, if toolbar icon is already active, all blocks and nodes contextual links are visible, but not the ones for my custom entity.
The button is there but not visible, because class `.visually-hidden` is still present on the element.
If I disable all links and enable again (by clicking on the toolbar icon), even the links for the custom entity are visible.
This is due to `adjustIfNestedAndOverlapping()` function called on `contextual.js`, which removes the class and hides nested contextual links anyhow, after adjusting the position.
$trigger.removeClass('visually-hidden');
height = $nestedContextual.height();
$trigger.addClass('visually-hidden');Proposed resolution
It's necessary to remove the class only if the state of contextual links is not visible.
| Comment | File | Size | Author |
|---|---|---|---|
| #11 | interdiff_6-11.txt | 1.86 KB | ranjith_kumar_k_u |
| #11 | 3054954-11.patch | 1.56 KB | ranjith_kumar_k_u |
| #6 | nested_contextual_links_3054954-4.patch | 1.91 KB | bladedu |
| #3 | nested_contextual_links_are_always_hidden_at_first_page_load-3054954.patch | 1.51 KB | noemi |
Comments
Comment #2
noemi commentedComment #3
noemi commentedComment #6
bladeduRe-rolled patch for Drupal 9.
Comment #9
larowlanSeems reasonable, is this something we can write a test for?
Comment #10
larowlanComment #11
ranjith_kumar_k_u commentedFixed CS errors.
Comment #14
smustgrave commentedThis issue is being reviewed by the kind folks in Slack, #needs-review-queue-initiative. We are working to keep the size of Needs Review queue [2700+ issues] to around 400 (1 month or less), following Review a patch or merge request as a guide.
For the tests in #9