An error occurred while fetching the assigned milestone of the selected merge_request.
Issue #3338283: Bootstrap 5: dropdown is too complicated
4 unresolved threads
Merge request reports
Activity
- Resolved by Florent Torregrosa
- Resolved by Florent Torregrosa
- Resolved by Florent Torregrosa
- Resolved by Florent Torregrosa
29 31 'auto_close': 'true', 30 'dropdown_tag': 'li', 31 'dropdown_navbar': true, 32 'attributes': create_attribute({ 33 'class': ['nav-item'] 34 }) 35 }, 'dropdown') }} 32 'tag': 'li', 33 'attributes': item_attributes.addClass('nav-item') 34 }) }} 36 35 {% else %} 37 <li{{ item.attributes.addClass('nav-item') }}> 38 {{ link(item.title, item.url) }} 36 <li{{ item_attributes.addClass('nav-item') }}> 37 {% if item.title and item.url %} 38 <a class="nav-link" href="{{ item.url }}">{{ item.title }}</a> I understand the logic of avoid Drupal specific Twig and also not rely on PHP object.
The problem of directly printing item.url and item.title is that attributes in the
<a>
tag are not handled whereas link() manage attributes. So for examples, attributes handled with menu link attributes, etc.changed this line in version 3 of the diff
- Resolved by Florent Torregrosa
- Resolved by Florent Torregrosa
added 1 commit
8 9 /** 10 * Handle variables needed for the pattern. 11 */ 12 class PreprocessPatternNavbarNav { 13 14 /** 15 * Handle variables needed for the pattern. 16 * 17 * @param array $variables 18 * The preprocessed variables. 19 */ 20 public function preprocess(array &$variables): void { 21 foreach ($variables['items'] as &$item) { 22 if (!($item['url'] instanceof Url)) { 23 $item['url'] = Url::fromUri($item['url']); changed this line in version 4 of the diff
- Resolved by Florent Torregrosa
64 - title: "Action" 65 url: "#" 66 - title: "Another action" 67 url: "#" 68 - title: "Dropdown item text" 69 - {} 70 - title: "Disabled link" 71 url: "#" 72 attributes: 73 class: 74 - disabled 75 - title: "Active link" 76 url: "#" 77 attributes: 78 class: 79 - active 59 content: 60 type: "menu" 61 label: "Content" 62 description: "A Drupal menu structure. Must be flat. Items without title are dividers. https://api.drupal.org/api/drupal/core!modules!system!templates!menu.html.twig/10.0.x" 63 preview: 64 - title: "Action" 65 url: "#" 66 - title: "Another action" 67 url: "#" 68 - title: "Dropdown item text" 69 - {} 70 - title: "Disabled link" 71 url: "#" 72 attributes: 73 class: 74 - disabled changed this line in version 3 of the diff
added 1 commit
added 1 commit
Please register or sign in to reply