[Discussion] Dropdown component, slot or prop?

Created on 21 December 2024, about 1 month ago

Problem/Motivation

Should we move the content of a dropdown to a slot or keep it as prop?

Content is currently a prop for links integration but does not allow using blocks.

πŸ“Œ Task
Status

Active

Version

5.1

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States mengi

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @mengi
  • πŸ‡«πŸ‡·France Grimreaper France πŸ‡«πŸ‡·

    Hi,

    Thanks for opening the issue so I can put my Slack response publicly:

    I am having nightmares with dropdown and navbar_nav, we had to rework it a lot since 2 years.

    So it is a prop for links integration.

    In https://git.drupalcode.org/project/sobki_profile_bootstrap/-/blob/10.0.x..., I have an example of simple_megamenu integration (UIP1 for the moment) and it acts on a hook_preprocess_menu that you may not have if using dropdown elsewhere.

    We can discuss with Pierre what would be the best:

    • override the dropdown component/create a new one on your side
    • try to inject your block in content and check how links prop type normalization happens and if we will have to adapt it in UIP2
  • πŸ‡«πŸ‡·France pdureau Paris

    Indeed, there is an example with a form in a dropdown in upstream doc: https://getbootstrap.com/docs/5.3/components/dropdowns/#forms

    We can imagine adding two slots: one before {% for item in content %}...{% endfor %} and one after.

    However, that would mean doing heavy and risky change in the HTML structure, without the guarantee to work properly at the end:

      {% if content %}
        {% if before %}
        <div{{ dropdown_menu_attributes }}>
          {{ before }}
          <ul>
        {% else %} 
          <ul{{ dropdown_menu_attributes }}>
        {% endif %}
        {% for item in content %}
    

    So, I advise not implementing this in the theme, and let users oiverriding the component if they need.

Production build 0.71.5 2024