Document clearly how contrib modules and/or site builders determine which content form buttons are primary

Created on 17 November 2024, 6 months ago

Problem/Motivation

Scenarios:

  • For most uses of Layout Builder Save And Edit β†’ , the "Save and edit layout" button should be in the main sticky area and "Save" should be relegated to the kebab menu, instead of the other way around.
  • ✨ Make adding action buttons to kebab menu optional Active mentions Entity Clone module (though i personally cannot think of a use case where i would want those primary rather than kebab, but the point is site builders know their use cases and should be able to control this)
  • Workflow Buttons β†’ should generally be outside the kebab (but already has to look for Gin specially ✨ Add actions to sticky header if using gin theme Fixed to work with Gin at all, so may not be applicable for this sort of API).
  • Any module that adds additional buttons or any content workflow that has non-standard priorities for different buttons.

Proposed resolution

Ideally there would be a common Drupal "primary/secondary" way to tag buttons that themes including Gin could use to display differently, put in the "more actions" Kebab menu, etc.

But anyhow Gin's way of doing this needs to be documented and exposed to modules and ultimately sitebuilders to choose.

I would be happy to maintain a contrib module that uses an API (or form alter) to allow site builders to choose which buttons are in the kebab menu or out of it, but first that API (or form alter) approach needs to be documented (and maybe exist first, but πŸ› Cannot opt out buttons using #gin_action_item = TRUE Active indicates it at least used to).

Remaining tasks

User interface changes

API changes

Data model changes

πŸ“Œ Task
Status

Active

Version

4.0

Component

Documentation

Created by

πŸ‡ΊπŸ‡ΈUnited States mlncn Minneapolis, MN, USA

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

Comments & Activities

  • Issue created by @mlncn
  • πŸ‡ΊπŸ‡ΈUnited States mlncn Minneapolis, MN, USA
  • πŸ‡ΊπŸ‡ΈUnited States mlncn Minneapolis, MN, USA

    Wanted to note that there is no mention of this primary / secondary (kebab menu) distinction in gin.api.php, and while it may be a different sort of thing than a classic API that's still a good place to document or point to other documentation.

    Also i can see that $form['actions']['submit']['#button_type'] = 'primary' but changing this value and setting other actions to primary does not affect anything Gin does.

    Now that themes can declare dependencies on modules β†’ , could we make a tiny, low-weighted module that Gin depends on that sets 'primary' to the actions that Gin thinks should be outside the kebab 'other actions' menu? Then regular-weight modules could further form alter this easily.

  • πŸ‡ΊπŸ‡ΈUnited States mlncn Minneapolis, MN, USA

    The merge request in πŸ› Cannot opt out buttons using #gin_action_item = TRUE Active restores an ability for third-party code to place buttons to the emphasized area outside of the kebab menu by adding in a form alter hook:

    $form['actions']['example_button']['#gin_action_item'] = TRUE;
    

    So as things stand the resolution to this issue is for that issue to be committed and closed as fixed and then for us to document it somewhere here – https://www.drupal.org/docs/contributed-themes/gin-admin-theme β†’ – and i think in gin.api.php also.

  • πŸ‡ΊπŸ‡ΈUnited States mlncn Minneapolis, MN, USA

    Hmm, actually we do need a bit more of an API than #gin_action_item or the code needs to be changed to allow an explicit ['#gin_action_item'] = FALSE to override Gin's hardcoded $include (used in includes/form.theme around line 90).

    Currently there is no way to move, say, the Save button into the Kebab when, say, the "Save and Edit Layout" should be primary.

  • πŸ‡©πŸ‡ͺGermany jurgenhaas Gottmadingen

    @mlncn with the latest changes in πŸ“Œ Improve sticky actions implementation Active my testing shows that:

    • '#gin_action_item' => TRUE works reliably
    • '#button_type' => 'primary' makes any visible button appear like a primary button
    • '#button_type' => 'normal' makes any visible button appear as normal, even if it were primary without that setting

    Please give that a try and let us know if you can confirm. If so, we can then put that status into the API documentation as you suggested.

  • πŸ‡¬πŸ‡·Greece iro

    I tested the cases described at #6 and they work as described. I tested all combinations.

  • πŸ‡©πŸ‡ͺGermany jurgenhaas Gottmadingen

    Thanks everyone.

  • πŸ‡¬πŸ‡·Greece iro

    For future reference, the test results in a glance:

  • πŸ‡¦πŸ‡ΉAustria hudri Austria

    I've added a section about sticky buttons in the docs:

    Custom theming docs β†’

  • πŸ‡¨πŸ‡­Switzerland saschaeggi Zurich

    Thank you hudri, added you to the issue credit

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

Production build 0.71.5 2024