Use polymorphic slots in ActionList and NavList #2042
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Reviewers: By approving this Pull Request you are approving the code change, as well as its deployment and mitigation plans.
Please read this description carefully. If you feel there is anything unclear or missing, please ask for updates.
What are you trying to accomplish?
This PR removes a couple of hacks in
ActionList
andNavList
that call a private view_component API method (i.e.#set_slot
) in order to fill in a slot with heterogeneous objects. The view_component framework offers a polymorphic slots feature tailor-made for such a use-case, but we haven't been able to make use of it... until now! I recently landed a feature that allows customization of polymorphic slot setter methods, which allows us to maintain backwards-compatibility with the existing public APIs of the two components in question and stop calling that private VC method.NavList
andActionList
both manage a list of items. These items can be regular 'ol items, dividers, or groups of items. Before the advent of dividers and groups, the public APIs of these components only offered a#with_item
method via theitems
slot. Converting theitems
slot into a polymorphic one would have caused the#with_item
method to become something like eg.#with_list_item
, while dividers could have been added via#with_item_divider
, etc. This is because slot setter methods were automatically generated and did not allow customization. As of view_component v3.1.0 however, slot setters can be completely customized.Integration
Yes. Dotcom will need to be upgraded to use view_component v3.1.0. This should be very little trouble however, since 3.1.0 is only a single minor version away from the version dotcom is currently using.
List the issues that this change affects.
Closes #2041
Risk Assessment
Accessibility
Merge checklist
Take a look at the What we look for in reviews section of the contributing guidelines for more information on how we review PRs.