Skip to content

Accept keyword arguments in render_in methods - #4091

Merged
jonrohan merged 2 commits into
mainfrom
render_in-kwargs
Jun 12, 2026
Merged

Accept keyword arguments in render_in methods#4091
jonrohan merged 2 commits into
mainfrom
render_in-kwargs

Conversation

@issyl0

@issyl0 issyl0 commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

Authors: Please fill out this form carefully and completely.

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?

  • Rails main now deprecates renderable objects whose render_in method only accepts a single positional argument. The args don't have to be used, hence why they're _ prefixed here: the arity check is very basic.
  • Uses of primer_view_components in applications on Rails main were seeing ActionView deprecation warnings:
  Change #render_in to accept keyword arguments.
   (called from block (2 levels) in FooComponent#call at app/components/foo_component.html.erb:8)
  DEPRECATION WARNING: Action View support for #render_in without options is deprecated.

Screenshots

N/A.

Integration

N/A.

List the issues that this change affects.

N/A (not linking the internal one).

Risk Assessment

  • Low risk the change is small, highly observable, and easily rolled back.
    - Building the gem from this branch locally fixed the deprecation warnings.
  • 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.

What approach did you choose and why?

  • See above.

Anything you want to highlight for special attention from reviewers?

N/A.

Merge checklist

  • Added/updated tests
  • Added/updated documentation
  • Added/updated previews (Lookbook)
  • Tested in Chrome
  • Tested in Firefox
  • Tested in Safari
  • Tested in Edge

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

- Rails `main` now[1] deprecates renderable objects whose `render_in`
  method only accepts a single positional argument. The args don't have
  to be used, hence why they're `_` prefixed here: the arity check is
  very basic.
- Uses of PrimerViewComponents in applications on Rails `main` were
  seeing ActionView deprecation warnings:

```
Change #render_in to accept keyword arguments.
  (called from block (2 levels) in FooComponent#call at app/components/foo_component.html.erb:8)
DEPRECATION WARNING: Action View support for #render_in without options is deprecated.
```

[1]: rails/rails@4870c5f)
@changeset-bot

changeset-bot Bot commented Jun 11, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 7aaac79

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 Patch

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

@issyl0
issyl0 marked this pull request as ready for review June 11, 2026 17:53
@issyl0
issyl0 requested a review from a team as a code owner June 11, 2026 17:53
@issyl0
issyl0 requested review from Copilot and francinelucca June 11, 2026 17:53

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates render_in method signatures across Primer components/forms to accept keyword arguments, aligning with Rails main’s deprecation of renderables whose render_in only accepts a single positional argument.

Changes:

  • Add **_kwargs to several render_in overrides to satisfy Rails’ arity/kwargs expectations.
  • Update form-related renderables (FormComponents, ToggleSwitchForm, ActsAsComponent) to accept keyword args.
  • Update TreeView and ButtonGroup internal components to accept keyword args in render_in.
Show a summary per file
File Description
lib/primer/form_components.rb Adjusts dynamically generated form component wrapper’s render_in to accept keyword args.
app/lib/primer/forms/toggle_switch_form.rb Updates render_in override to accept keyword args while still building a builder at render time.
app/lib/primer/forms/acts_as_component.rb Updates renderable mixin’s render_in signature to accept keyword args.
app/components/primer/beta/button_group.rb Updates MenuButton#render_in signature to accept keyword args (but currently doesn’t forward them to super).
app/components/primer/alpha/tree_view/visual.rb Updates TreeView visual wrapper render_in to accept keyword args.
app/components/primer/alpha/tree_view/sub_tree_node.rb Updates subtree node render_in wrapper to accept keyword args.

Copilot's findings

  • Files reviewed: 6/6 changed files
  • Comments generated: 1

Comment thread app/components/primer/beta/button_group.rb
@francinelucca
francinelucca requested review from jonrohan and removed request for francinelucca June 12, 2026 01:53
Allow `render_in` methods to accept keyword arguments.
@jonrohan
jonrohan enabled auto-merge (squash) June 12, 2026 18:29
@jonrohan
jonrohan merged commit ff6cc0d into main Jun 12, 2026
32 checks passed
@jonrohan
jonrohan deleted the render_in-kwargs branch June 12, 2026 18:39
@primer primer Bot mentioned this pull request Jun 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants