Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use polymorphic slots in ActionList and NavList #2042

Merged
merged 4 commits into from
Jun 12, 2023

Conversation

camertron
Copy link
Contributor

@camertron camertron commented Jun 1, 2023

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 and NavList 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 and ActionList 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 the items slot. Converting the items 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

  • Low risk the change is small, highly observable, and easily rolled back.
  • Medium risk changes that are isolated, reduced in scope or could impact few users. The change will not impact library availability.
  • High risk changes are those that could impact customers and SLOs, low or no test coverage, low observability, or slow to rollback.

Accessibility

  • No new axe scan violation - This change does not introduce any new axe scan violations.

Merge checklist

  • Added/updated documentation

Take a look at the What we look for in reviews section of the contributing guidelines for more information on how we review PRs.

@changeset-bot
Copy link

changeset-bot bot commented Jun 1, 2023

🦋 Changeset detected

Latest commit: 72cc313

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@primer/view-components Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions bot added the ruby Pull requests that update Ruby code label Jun 1, 2023
@camertron camertron temporarily deployed to preview June 1, 2023 04:22 — with GitHub Actions Inactive
@camertron camertron temporarily deployed to github-pages June 1, 2023 04:26 — with GitHub Actions Inactive
@camertron camertron marked this pull request as ready for review June 1, 2023 04:27
@camertron camertron requested review from a team, keithamus and jonrohan and removed request for keithamus June 1, 2023 04:27
@camertron camertron temporarily deployed to preview June 1, 2023 20:53 — with GitHub Actions Inactive
@camertron camertron temporarily deployed to github-pages June 1, 2023 20:57 — with GitHub Actions Inactive
@jonrohan jonrohan merged commit 9c53f8e into main Jun 12, 2023
@jonrohan jonrohan deleted the polymorphic_nav_list_slots branch June 12, 2023 15:25
@primer-css primer-css mentioned this pull request Jun 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
minor release ruby Pull requests that update Ruby code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Clean up usages of private view_component #set_slot method in ActionList and NavList
2 participants