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

[core] fix(PanelStack2): improve types for common use cases #4570

Merged
merged 5 commits into from
Mar 10, 2021

Conversation

adidahiya
Copy link
Contributor

@adidahiya adidahiya commented Mar 9, 2021

Fixes #4272 again, in a better way, building on #4541

Checklist

  • Includes tests
  • Update documentation

Changes proposed in this pull request:

#4541 wasn't a very good change because it constrained PanelStack2 to only working with homogenous panels in a panel stack. The docs example was very simple and did not reflect typical panel stack usage where there are usually heterogenous panels with different info and actions on each one. This PR updates the docs example to this kind of heterogenous use case. It also adds a second generic type param which allows us to fix #4272 while being explicit (more type safe) about which kinds of panel interfaces are allowed in a particular panel stack.

The generic type param for PanelStack2Props and PanelStack2 has been changed to one that represents a Panel<P> object. When this generic T is specified (or inferred) as the type union of all possible panels in the stack, we get accurate types for onOpen and onClose, fixing #4272.

Reviewers should focus on:

Check out the new API in use in docs-app, check out the updated documentation, JSDoc comments...

@adidahiya adidahiya requested a review from invliD March 9, 2021 23:46
@blueprint-bot
Copy link

tweak PanelStack2 types some more

Previews: documentation | landing | table

@blueprint-bot
Copy link

simplify types

Previews: documentation | landing | table

@blueprint-bot
Copy link

update tests

Previews: documentation | landing | table

@blueprint-bot
Copy link

Merge remote-tracking branch 'origin/develop' into ad/panel-stack2-redux

Previews: documentation | landing | table

@adidahiya adidahiya changed the title [core] fix(PanelStack2): improve types to support common use cases [core] fix(PanelStack2): improve types for common use cases Mar 10, 2021
@adidahiya adidahiya merged commit 2cdd00a into develop Mar 10, 2021
@adidahiya adidahiya deleted the ad/panel-stack2-redux branch March 10, 2021 20:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

PanelStack: onOpen, onClose and initialPanel prop should use type argument P
2 participants