Skip to content

feat(GlDisclosureDropdown): Tweak action/link logic

Mark Florian requested to merge change-disclosure-action-item-determination into main

What does this MR do?

test(GlDisclosureDropdown): Specify action args

This adds explicit assertions about how the action callback is called on disclosure items. This will make it clearer how the following commits change how the callback is called.


feat(GlDisclosureDropdown): Pass item to action

BREAKING CHANGE: The this of the GlDisclosureDropdown action callback is now undefined rather than the item it's attached to. It now receives the item as a regular argument instead.

This makes it more similar to the action event that's emitted by the component, such that the same function could be used in either way.

This also means that the same callback can be attached to all items, instead of requiring a unique callback for each item.


feat(GlDisclosureDropdown): Loosen action item type

This allows for a simpler way of specifying action items. They no longer need an action method. They simply must not have an href string.

This means that if all items are actions, you can simply provide their text, and then add an action event listener to the root component, rather than add an action listener to each item. It is also still possible to add unique action handlers for each item.

BREAKING CHANGE: Action items are now determined by the lack of an href string. An item with an href string is rendered as a link item, whether or not it has an action callback.

Before this change, if an item had both an href and an action, it would render as a button. Now, it would render as an anchor.


docs(GlDisclosureDropdown): Prettify example markup

Does this MR meet the acceptance criteria?

Conformity

  • Code review guidelines.
  • GitLab UI's contributing guidlines.
  • If it changes a Pajamas-compliant component's look & feel, the MR has been reviewed by a UX designer.
  • If it changes GitLab UI's documentation guidelines, the MR has been reviewed by a Technical Writer.
  • If the MR changes a component's API, integration MR(s) have been opened in the following projects to ensure that the @gitlab/ui package can be upgraded quickly after the changes are released:
  • Added the ~"component:*" label(s) if applicable.

Security

If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:

  • Label as security and @ mention @gitlab-com/gl-security/appsec
  • Security reports checked/validated by a reviewer from the AppSec team

Accessibility

If this MR adds or modifies a component, take a few moments to review the following:

  • All actions and functionality can be done with a keyboard.
  • Links, buttons, and controls have a visible focus state.
  • All content is presented in text or with a text equivalent. For example, alt text for SVG, or aria-label for icons that have meaning or perform actions.
  • Changes in a component’s state are announced by a screen reader. For example, changing aria-expanded="false" to aria-expanded="true" when an accordion is expanded.
  • Color combinations have sufficient contrast.
Edited by Mark Florian

Merge request reports