Add consistent layout and state for actions and a button action template.

Review Request #14423 — Created May 4, 2025 and submitted

Information

Review Board
release-7.1.x

Reviewers

This introduces a few changes to help write actions and ensure they work
in a consistent way in multiple places.

There's now an action_base.html template that handles the general
structure of an action. This provides the parent rb-c-actions__action
container with some consistent attributes, plus template variables for
use in derived templates. Derived templates can use this to build their
elements and to influence the parent container state.

This gives us more consistent templates and helps us set some new
attributes for visibility management. We use both hidden and
display: none (the latter being necessary since display can override
the former). From that, we can better manage the accessibility tree and
check for state more directly.

RB.ActionView provides the other end of the visibility management.
Visibility is now managed on the parent action container element, if
used, so that we don't end up with empty <li> elements affecting
layout when actions are hidden. If nested in another container (such as
a menu), the action's own element is used.

ActionView.show() and hide() update both display and hidden,
using the visibility element. An isVisible() method returns the state
based on that as well.

Along with this, there are a few small typing and function signature
fixes I hit during development, plus error handling when action
templates fail to render.

These will make it easier to implement some new action functionality
coming in a follow-up change.

Tested all the current actions in the UI, looking for visual breakages
or issues invoking the actions.

Unit tests pass.

Tested the new functionality with in-progress changes.

Summary ID
Add consistent layout and state for actions and a button action template.
This introduces a few changes to help write actions and ensure they work in a consistent way in multiple places. There's now an `action_base.html` template that handles the general structure of an action. This provides the parent `rb-c-actions__action` container with some consistent attributes, plus template variables for use in derived templates. Derived templates can use this to build their elements and to influence the parent container state. This gives us more consistent templates and helps us set some new attributes for visibility management. We use both `hidden` and `display: none` (the latter being necessary since `display` can override the former). From that, we can better manage the accessibility tree and check for state more directly. `RB.ActionView` provides the other end of the visibility management. Visibility is now managed on the parent action container element, if used, so that we don't end up with empty `<li>` elements affecting layout when actions are hidden. If nested in another container (such as a menu), the action's own element is used. `ActionView.show()` and `hide()` update both `display` and `hidden`, using the visibility element. An `isVisible()` method returns the state based on that as well. Along with this, there are a few small typing and function signature fixes I hit during development, plus error handling when action templates fail to render. These will make it easier to implement some new action functionality coming in a follow-up change.
19dd1e982b4268359b672e03331860d5604bdf68
Description From Last Updated

'typing.ClassVar' imported but unused Column: 1 Error code: F401

reviewbotreviewbot

Looks like there are a couple more in this file that need this fix, as well as some in reviewboard/accounts/actions.py

daviddavid
Checks run (1 failed, 1 succeeded)
flake8 failed.
JSHint passed.

flake8

chipx86
chipx86
chipx86
chipx86
david
  1. 
      
  2. reviewboard/reviews/actions.py (Diff revision 5)
     
     
    Show all issues

    Looks like there are a couple more in this file that need this fix, as well as some in reviewboard/accounts/actions.py

  3. 
      
chipx86
chipx86
chipx86
david
  1. Ship It!
  2. 
      
maubin
  1. Ship It!
  2. 
      
chipx86
Review request changed
Status:
Completed
Change Summary:
Pushed to release-7.1.x (84db655)