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

breaking(Portal): use createPortal() API #2755

Merged
merged 8 commits into from
May 13, 2018
Merged

Conversation

layershifter
Copy link
Member

@layershifter layershifter commented May 1, 2018

BREAKING

Why?

Our Portal component relies on unstable_renderSubtreeIntoContainer, this API is deprecated and will be removed in future releases of React. Also, this causes problems with tests.

1. Requirement of React 16

React 16 was released in September 2017, the update process is simple and I don't know any supported application that still uses React 15. It's time to say goodbye to React 15.

Please keep in mind, that in near future we will possibly require React 16.3.

2. Removal of className prop

As we use the new API (createPortal()) we don't need wrapper nodes as was before, so we don't have a target where we can apply className.

Before

<Portal className='foo'>
  <button>A button</button>
</Portal>

After

<Portal>
  <div className='foo'>
    <button>A button</button>
  </div>
</Portal>

3. Removal of prepend prop

Now, we don't control DOM manipulations, so this prop is useless now.

4. Removal of closeOnRootNodeClick

Now, we don't have rootNode at all, createPortal is responsible for DOM manipulations.


Fixes #2746.

render() {
const { children, mountNode = isBrowser() ? document.body : null } = this.props

return createPortal(<Ref innerRef={this.handleRef}>{children}</Ref>, mountNode)
Copy link
Member Author

Choose a reason for hiding this comment

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

We need a valid ref to get working closeOnDocumentClick as now we don't have rootNode and portalNode in fact

@@ -21,12 +21,10 @@ class ModalExampleCloseConfig extends Component {
<Modal
open={open}
closeOnEscape={closeOnEscape}
closeOnRootNodeClick={closeOnRootNodeClick}
closeOnDimmerClick={closeOnDimmerClick}
Copy link
Member Author

Choose a reason for hiding this comment

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

closeOnRootNodeClick was not correct there

@codecov-io
Copy link

codecov-io commented May 3, 2018

Codecov Report

Merging #2755 into react-16 will decrease coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@             Coverage Diff              @@
##           react-16    #2755      +/-   ##
============================================
- Coverage     99.74%   99.74%   -0.01%     
============================================
  Files           160      161       +1     
  Lines          2762     2745      -17     
============================================
- Hits           2755     2738      -17     
  Misses            7        7
Impacted Files Coverage Δ
src/addons/Portal/Portal.js 100% <100%> (ø) ⬆️
src/modules/Modal/Modal.js 100% <100%> (ø) ⬆️
src/addons/Portal/PortalInner.js 100% <100%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6a22434...a996ad5. Read the comment docs.

@levithomason
Copy link
Member

What do you think about making a react-16-3 branch for this? I know only 16.0 is required, but we can also bundle the ref changes into that branch. This way, we can gather all of our changes that require React >=16.3 and make one breaking release once it is all ready.

Linking #2747.

@layershifter
Copy link
Member Author

I know only 16.0 is required, but we can also bundle the ref changes into that branch.

In this case I think it will be better if we ship this PR now. forwardRef is more complicated thing in fact.

@levithomason
Copy link
Member

OK, let's merge this into a react-16 branch. I don't want to drop React 15 users on the next release.

@layershifter layershifter changed the base branch from master to react-16 May 13, 2018 13:01
@layershifter
Copy link
Member Author

@levithomason I've changed base to react-16 branch and merged.

@layershifter layershifter merged commit c33a720 into react-16 May 13, 2018
@layershifter layershifter deleted the feat/portal-16 branch May 13, 2018 13:14
layershifter added a commit that referenced this pull request Jun 29, 2018
* breaking(Portal): use createPortal() API (#2755)

* breaking(Portal): use createPortal() API

* test(Portal): rewrite tests

* test(Portal): rewrite tests

* fix(Portal): mixed fixes in tests

* fix(Portal): fix path of typings

* feat(Flag|Icon): use PureComponent instead of shallowEqual() (#2842)

* fix(IconSearch): remove prop

* fix(PortalInner): remove meta

* fix(Portal): fix broken test

* fix(Modal): go away from rootNode

* fix(Flag|Icon): remove unused import

* feat(Portal): add `triggerRef` prop (#2902)

* feat(Portal): add `triggerRef` prop

* test(Portal): add test for `triggerRef` prop

* fix(Popup): fix test

* BREAKING(Accordion): refactor shorthand API to use AccordionPanel (#2904)

* refactor(Accordion): simplify render with AccordionPanel

* style(Accordion): add description

* fix(tests): reenable throw on console.log()

* style(mixed): lint issues in typings

* fix yarn.lock

* fix(ComponentDocLinks): add rel="noopener noreferrer"

* revert styling changes

* restore yarn.lock from master

* style(Portal): remove render method
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