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

Explicitly convert params to integers where needed in previews #2735

Merged
merged 2 commits into from
Mar 28, 2024

Conversation

antn
Copy link
Contributor

@antn antn commented Mar 28, 2024

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?

Fixes #2734.

When you change a param in lookbook, that value gets sent as a string, even if it is a number. We have different components where we allow changing the number of things rendered, and if you try to change the number, it errors currently because we are passing in a string instead of an integer.

This PR just updates those previews to call .to_i, if the param is present. I've confirmed that this fixes changing the params for these previews in lookbook.

Risk Assessment

  • Low risk the change is small, highly observable, and easily rolled back.

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

@antn antn self-assigned this Mar 28, 2024
@antn antn requested a review from a team as a code owner March 28, 2024 07:31
@antn antn requested a review from pksjce March 28, 2024 07:31
Copy link

changeset-bot bot commented Mar 28, 2024

🦋 Changeset detected

Latest commit: ad69381

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

@jonrohan jonrohan merged commit 507a743 into main Mar 28, 2024
30 checks passed
@jonrohan jonrohan deleted the preview-string-to-int-conv branch March 28, 2024 16:24
@primer primer bot mentioned this pull request Mar 28, 2024
@camertron
Copy link
Contributor

Huh, I'm surprised Lookbook doesn't automatically coerce these to integers. Might be worth an upstream PR?

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.

Changing params for component preview gives no implicit conversion of String into Integer error
3 participants