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-12205 Add WithTransition wrapper component to enable "controlled" transitions using props #621

Merged
merged 9 commits into from
Sep 30, 2020

Conversation

aaronlademann-wf
Copy link
Contributor

@aaronlademann-wf aaronlademann-wf commented Aug 25, 2020

Motivation

Currently, AbstractTransitionComponents can only be programmatically shown/hidden using the show / hide / toggle API methods on the instance.

With React 16 componentry - this is not ideal since calling the methods from a parent component requires the use of a ref, and the child component is no longer guaranteed to have been mounted when the parent component is. This makes it very difficult to hide/show things within data-driven applications without having to work around runtime race conditions.

Changes

  1. Add the WithTransition wrapper component.
    This component is designed to have identical behavior to AbstractTransitionComponent, but allows the consumer to control the behavior using the value of props.isShown.
  2. Add tests.

Release Notes

Add WithTransition wrapper component to enable "controlled" transitions using props

QA Checklist

  • Tests were updated and provide good coverage of the changeset and other affected code

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

@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.

@aaronlademann-wf aaronlademann-wf force-pushed the controlled-abstract-transition branch from 8722965 to 8d23802 Compare August 25, 2020 23:53
@aaronlademann-wf aaronlademann-wf force-pushed the controlled-abstract-transition branch 3 times, most recently from 7fc288d to c8b72ed Compare September 11, 2020 21:04
@aaronlademann-wf aaronlademann-wf changed the title [WIP] Allow AbstractTransitionComponents to be controlled with props Allow AbstractTransitionComponent implementations to be "controlled" with props Sep 15, 2020
@aaronlademann-wf aaronlademann-wf force-pushed the controlled-abstract-transition branch from c8b72ed to cc1dd22 Compare September 16, 2020 15:15
@rm-astro-wf rm-astro-wf changed the title Allow AbstractTransitionComponent implementations to be "controlled" with props CPLAT-12205 Allow AbstractTransitionComponent implementations to be "controlled" with props Sep 16, 2020
@aaronlademann-wf aaronlademann-wf force-pushed the controlled-abstract-transition branch from cc1dd22 to 591a79a Compare September 16, 2020 15:30
Copy link
Contributor

@joebingham-wk joebingham-wk left a comment

Choose a reason for hiding this comment

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

This all looks awesome! I just have one question, but it's a small one, and then I'm +1!

lib/src/component/abstract_transition.dart Outdated Show resolved Hide resolved
Copy link
Contributor

@greglittlefield-wf greglittlefield-wf left a comment

Choose a reason for hiding this comment

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

Given the getDerivedStateFromProps issues and deprecation concerns, is it possible to add controlled behavior to this component cleanly?

We might be better off starting fresh with a new TransitionPrimitive component that's entirely props-based

lib/src/component/abstract_transition.dart Outdated Show resolved Hide resolved
lib/src/component/abstract_transition.dart Outdated Show resolved Hide resolved
lib/src/component/abstract_transition.dart Outdated Show resolved Hide resolved
lib/src/component/abstract_transition.dart Outdated Show resolved Hide resolved
@aaronlademann-wf aaronlademann-wf force-pushed the controlled-abstract-transition branch from 591a79a to 963915a Compare September 22, 2020 17:13
@aaronlademann-wf aaronlademann-wf changed the title CPLAT-12205 Allow AbstractTransitionComponent implementations to be "controlled" with props CPLAT-12205 Add WithTransition wrapper component to enable "controlled" transitions using props Sep 22, 2020
@aaronlademann-wf
Copy link
Contributor Author

aaronlademann-wf commented Sep 25, 2020

@greglittlefield-wf can you be more specific with what you're seeing as far as breaking the rules of hooks?

All tests we used for the old component are passing, and we have a consumer +10.

@greglittlefield-wf
Copy link
Contributor

@aaronlademann-wf Mostly around dependencies in useEffect/useLayoutEffect, and the complexity of the nested calls to render closures inside useLayoutEffect; see my last couple comments on the code

@greglittlefield-wf
Copy link
Contributor

All tests we used for the old component are passing, and we have a consumer +10.

The current component has more edge cases and potentially incorrect code paths with the way it uses hooks, so I don't think that's enough to say the component in it's current state is bug-free.

Bugs introduced by improper uses of hooks might not always be surfaced in simple usages / tests, but rather by sequences of rerenders.

In this case, what about if you rerender the component when

@aaronlademann-wf
Copy link
Contributor Author

@greglittlefield-wf I have addressed your feedback.

+ Based on CR feedback that the functional patterns were not a good fit / robust enough to handle edge cases.
lib/src/component/with_transition.dart Outdated Show resolved Hide resolved
lib/src/component/with_transition.dart Outdated Show resolved Hide resolved
lib/src/component/with_transition.dart Outdated Show resolved Hide resolved
lib/src/component/with_transition.dart Show resolved Hide resolved
lib/src/component/with_transition.dart Outdated Show resolved Hide resolved
lib/src/component/with_transition.dart Outdated Show resolved Hide resolved
lib/src/component/with_transition.dart Outdated Show resolved Hide resolved
@maxwellpeterson-wf
Copy link
Member

+10

@greglittlefield-wf
Copy link
Contributor

@Workiva/release-management-p

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

@rmconsole5-wk rmconsole5-wk merged commit 60da93d into master Sep 30, 2020
@rmconsole5-wk rmconsole5-wk deleted the controlled-abstract-transition branch September 30, 2020 19:39
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.

7 participants