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

CPLAT-15063 Conditionally unconvert style and children props #698

Merged
merged 2 commits into from
Aug 4, 2021

Conversation

greglittlefield-wf
Copy link
Contributor

@greglittlefield-wf greglittlefield-wf commented Jul 30, 2021

Motivation

Sometimes, Dart code can read props that originate from JS code (e.g., a JS component rendering/cloning a Dart component), and in cases where the JS prop value doesn't match the typings on the OverReact prop getter, you get a runtime type error.

Two common cases of this are the style and children props.

style props set by JS code are JS objects, which can't be casted to Dart Maps in the DomPropsMixin.style and UbiquitousDomPropsMixin.style getters.

children props are always Lists for Dart components rendered by Dart code, but can be nullish or a singular value when rendered by JS components, and can cause cast errors in the typed children prop getter.

Changes

  • Normalize the value of the children prop getter (ReactPropsMixin.children, mixed into UiProps) to always be a List
  • Normalize the value of the style prop getters (UbiquitousDomPropsMixin.style, mixed into UiProps, and DomPropsMixin.style) to convert JS object values to Dart Maps
  • Add tests

Release Notes

Review

See CONTRIBUTING.md for more details on review types (+1 / QA +1 / +10) and code review process.

Please review:

QA Checklist

  • Tests were updated and provide good coverage of the changeset and other affected code
  • Manual testing was performed if needed

Merge Checklist

While we perform many automated checks before auto-merging, some manual checks are needed:

  • A Client Platform member has reviewed these changes
  • There are no unaddressed comments - this check can be automated if reviewers use the "Request Changes" feature
  • For release PRs - Version metadata in Rosie comment is correct

…t type

For instance, when a JS component/library renders a Dart component and passes
it a single value for children, or a JS object for style
/// The children that were passed in to this component when it was built.
List children;
List<dynamic> get children {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I inlined this implementation into the getter, as opposed to making it a utility function, so that I could do props.containsKey('children') below

@aviary-wf
Copy link

Security Insights

No security relevant content was detected by automated scans.

Action Items

  • Review PR for security impact; comment "security review required" if needed or unsure
  • Verify aviary.yaml coverage of security relevant code

Questions or Comments? Reach out on Slack: #support-infosec.

@rmconsole4-wk rmconsole4-wk changed the title Conditionally unconvert style and children props CPLAT-15063 Conditionally unconvert style and children props Aug 2, 2021
@greglittlefield-wf greglittlefield-wf marked this pull request as ready for review August 2, 2021 21:27
Copy link
Contributor

@aaronlademann-wf aaronlademann-wf left a comment

Choose a reason for hiding this comment

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

This looks great! Awesome test coverage!

Copy link
Contributor

@aaronlademann-wf aaronlademann-wf left a comment

Choose a reason for hiding this comment

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

-1

Copy link
Contributor

@aaronlademann-wf aaronlademann-wf left a comment

Choose a reason for hiding this comment

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

+1

w_table consumer test failures were a red herring

+10

  • Dart 2.7.2 / Stable CI builds and tests passed
  • consumer tests with the exception of a few known flaky tests passed

@Workiva/release-management-pp

Copy link

@rmconsole-wf rmconsole-wf left a comment

Choose a reason for hiding this comment

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

+1 from RM

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.

5 participants