Give action templates more control over presentation and attributes.
Review Request #14701 — Created Nov. 19, 2025 and submitted
Action templates all inherit from
action_base.html, which has two
modes:
Presenting top-level actions, which have a
rb-c-actions__action
container with an ID, visibility attributes, and more.Presenting inner actions, which don't have a container but do manage
an ID and visibility attributes.There was no control over that container element in templates, and the
attribute and visibility management was a bit all over the place. Any
child of a group was invisible by default, which is really only
appropriate for the default style of non-Ink menu item.The old template made it a real challenge to create maintainable
actions, and was impacting the new sidebar action support, so it's been
reworked.The new template defines all the following blocks for various bits of
control:
-
action_is_visible: Controls visibility of the action. Can contain
trueor any other value forfalse. Defaults to the action's
visiblestate. -
action_has_container: Controls the presence of a default container
element. Defaults totrueif it's a top-level action. -
action_container_tag: The HTML tag for the container element.
Defaults toli. -
action_container_css_class: Any additional CSS classes for the
container element. -
action_attrs: DOM attributes suitable for the inner element.
Defaults to including an ID and visibility attributes if
action_has_container=False. -
action_container_attrs: DOM attributes suitable for the container
element. Defaults to including an ID and visibility attributes if
action_has_container=True. -
action_container_role: The role for the container element. Defaults
topresentation. -
action_container_start: The start tag for the container element. -
action_container_end: The end tag for the container element. -
action_content: The content of the action.
There are some structural changes that are important for consistency
with flexible rendering:
-
Action IDs are now always set for the inner element, and not the
container element. This provides consistency. Before, it was
dependent on where the action was rendered. -
Because of that, actions should now be wrapped in one element,
regardless of a container, so it may have an ID associated. The menu
action, for instance, now has an inner wrapper element for the ID
with a label. -
Visibility is still on the container action for top-level actions,
and the inner element for inner actions. The JavaScript still manages
this properly. Actions are no longer hidden by default if they're
inside another group. -
The visibility changes uncovered a bug in menu items where, due
to being directly parented to therb-c-actions__actioncontainer
element of the parent menu, they fetched the wrong visibility
element. Since they're not intended to be shown (menus get rebuilt
with their information), we now wrap them in a hidden div so they
never display.
The menu template is adapted to support the new functionality and to
cover the use cases we were special-casing everywhere. The custom
Archive and Account menus have been moved over to use the improved
template. This all needed to be done in the same change due to the
impact on these templates.
This change requires the new changes up for review in Djblets 5.3 for
{% definevar as_type= %}.
Tested the appearance and interactivity of all actions, with close
attention paid to the various menu actions.Tested new in-progress action renderers for sidebars.
Unit tests pass.
| Summary | ID |
|---|---|
| e4d4c92ede1689dc100bc9c305400d1d83f73bfd |
| Description | From | Last Updated |
|---|---|---|
|
In your description, the explanation for action_container_role says "Defaults" at the end with no finish. |
|
|
|
In your description, "There are some couple structural changes..." |
|
|
|
In your description, item 4: "... uncovered a bug in menu items where. Due to being..." |
|
|
|
It might be nice to have a big comment at the top of this that lists out the blocks that … |
|
|
|
Browsers ignore role="presentation" on focusable elements like <a> tags. |
|
|
|
Can we use a CSS rule for div[hidden] to do this, instead of needing the inline style attribute? This probably … |
|
|
|
Nit but we could just make a variable for placement.parent_id is not None and then give has_parent the value and … |
|
-
-
In your description, the explanation for
action_container_rolesays "Defaults" at the end with no finish. -
-
-
It might be nice to have a big comment at the top of this that lists out the blocks that can be defined in templates that extend this (basically what you have in your commit message).
-
-
Can we use a CSS rule for
div[hidden]to do this, instead of needing the inline style attribute?This probably also needs
aria-hidden="true"
- Change Summary:
-
Added a doc comment at the top of the
action_base.htmltemplate. - Description:
-
Action templates all inherit from
action_base.html, which has twomodes: -
Presenting top-level actions, which have a
rb-c-actions__action
container with an ID, visibility attributes, and more.
-
Presenting inner actions, which don't have a container but do manage
an ID and visibility attributes.
There was no control over that container element in templates, and the
attribute and visibility management was a bit all over the place. Any child of a group was invisible by default, which is really only appropriate for the default style of non-Ink menu item. The old template made it a real challenge to create maintainable
actions, and was impacting the new sidebar action support, so it's been reworked. The new template defines all the following blocks for various bits of
control: -
action_is_visible: Controls visibility of the action. Can contain
trueor any other value forfalse. Defaults to the action's
visiblestate.
-
action_has_container: Controls the presence of a default container
element. Defaults totrueif it's a top-level action.
-
action_container_tag: The HTML tag for the container element.
Defaults toli.
-
action_container_css_class: Any additional CSS classes for the
container element.
-
action_attrs: DOM attributes suitable for the inner element.
Defaults to including an ID and visibility attributes if
action_has_container=False.
-
action_container_attrs: DOM attributes suitable for the container
element. Defaults to including an ID and visibility attributes if
action_has_container=True.
~ -
action_container_role: The role for the container element. Defaults
~ -
action_container_role: The role for the container element. Defaults
topresentation.
-
action_container_start: The start tag for the container element.
-
action_container_end: The end tag for the container element.
-
action_content: The content of the action.
~ There are some couple structural changes that are important for
~ consistency with flexible rendering: ~ There are some structural changes that are important for consistency
~ with flexible rendering: -
Action IDs are now always set for the inner element, and not the
container element. This provides consistency. Before, it was
dependent on where the action was rendered.
-
Because of that, actions should now be wrapped in one element,
regardless of a container, so it may have an ID associated. The menu
action, for instance, now has an inner wrapper element for the ID
with a label.
-
Visibility is still on the container action for top-level actions,
and the inner element for inner actions. The JavaScript still manages
this properly. Actions are no longer hidden by default if they're
inside another group.
~ -
The visibility changes uncovered a bug in menu items where. Due
to being directly parented to therb-c-actions__actioncontainer
element of the parent menu, they fetched the wrong visibility
element. Since they're not intended to be shown (menus get rebuilt
with their information), we now wrap them in a hidden div so they
never display.
~ -
The visibility changes uncovered a bug in menu items where, due
to being directly parented to therb-c-actions__actioncontainer
element of the parent menu, they fetched the wrong visibility
element. Since they're not intended to be shown (menus get rebuilt
with their information), we now wrap them in a hidden div so they
never display.
The menu template is adapted to support the new functionality and to
cover the use cases we were special-casing everywhere. The custom Archive and Account menus have been moved over to use the improved template. This all needed to be done in the same change due to the impact on these templates. This change requires the new changes up for review in Djblets 5.3 for
{% definevar as_type= %}. -
- Commits:
-
Summary ID f73a8b5bebd2a727906d8adc9e5ce15a55168144 96c54ed1093b0a992f111392d25c2d3cedf4be2b - Diff:
-
Revision 2 (+506 -286)
Checks run (2 succeeded)
- Change Summary:
-
Updated HTML in unit tests based on updates to the group renderer changes.
- Commits:
-
Summary ID 96c54ed1093b0a992f111392d25c2d3cedf4be2b e4d4c92ede1689dc100bc9c305400d1d83f73bfd - Diff:
-
Revision 3 (+552 -356)
Checks run (2 succeeded)
-
-
Nit but we could just make a variable for
placement.parent_id is not Noneand then givehas_parentthe value andis_toplevelthe opposite of the value.I wonder if we should even have two separate context variables for this, if they're always just going to be the opposite of eachother? With the rewrites we don't seem to use
has_parentanywhere anymore.