Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 140
Rework dash-renderer setProps#478
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
35f30f547fa1a78ae3db69e3613fd053565409985ff1a714ddf57e120a0b9ca6a4132ee380a6fe4144213fdf0ec59d849923e7dab7f44431c7e3fc8a28f123f73de52fe2e8156ac1cd78e7eec99eaf8bacbbe0014c4e419973a47aeaf4255cbb33cad3f877af0c2434a69306bFile filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Uh oh!
There was an error while loading. Please reload this page.
Large diffs are not rendered by default.
Uh oh!
There was an error while loading. Please reload this page.
Large diffs are not rendered by default.
Uh oh!
There was an error while loading. Please reload this page.
Large diffs are not rendered by default.
Uh oh!
There was an error while loading. Please reload this page.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Uh oh!
There was an error while loading. Please reload this page.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,4 @@ | ||
| import {clone} from 'ramda'; | ||
| import React from 'react'; | ||
| import PropTypes from 'prop-types'; | ||
| @@ -31,20 +32,18 @@ export default class ConfirmDialogProvider extends React.Component { | ||
| const displayed = this.state.displayed; | ||
| // Will lose the previous onClick of the child | ||
| const wrapClick = child => | ||
| React.cloneElement(child, { | ||
| onClick: () => { | ||
| const update = {displayed: true}; | ||
| this.setState(update); | ||
| if (setProps) { | ||
| setProps(update); | ||
| } | ||
| }, | ||
| }); | ||
| const wrapClick = child => { | ||
| const props = clone(child.props); | ||
| props._dashprivate_layout.props.onClick = () => { | ||
| const update = {displayed: true}; | ||
| this.setState(update); | ||
| if (setProps) { | ||
| setProps(update); | ||
| } | ||
| }; | ||
ContributorAuthor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Like before, inserting | ||
| const realChild = children.props | ||
| ? children.props.children | ||
| : children.map(e => e.props.children); | ||
| return React.cloneElement(child, props); | ||
| }; | ||
| return ( | ||
| <div | ||
| @@ -53,9 +52,9 @@ export default class ConfirmDialogProvider extends React.Component { | ||
| (loading_state && loading_state.is_loading) || undefined | ||
| } | ||
| > | ||
| {realChild && realChild.length | ||
| ? realChild.map(wrapClick) | ||
| : wrapClick(realChild)} | ||
| {Array.isArray(children) | ||
| ? children.map(wrapClick) | ||
| : wrapClick(children)} | ||
alexcjohnson marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| <ConfirmDialog {...this.props} displayed={displayed} /> | ||
| </div> | ||
| ); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -177,12 +177,7 @@ describe('Tabs handle Tab selection logic', () => { | ||
| }); | ||
| test('Tab can be clicked and will display its content', () => { | ||
| tabs.find('[value="tab-2"]').simulate('click'); | ||
| const renderedContent = tabs.find('.tab-content > div').html(); | ||
| expect(renderedContent).toEqual('<div>Tab 2 child</div>'); | ||
| }); | ||
| test('Tab without value will still be clickable', () => { | ||
| tabs.find('[value="tab-2"]').simulate('click'); | ||
| const renderedContent = tabs.find('.tab-content > div').html(); | ||
ContributorAuthor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This test is an exact copy of the test above. Looks like copy-paste that was never modified. Removing. | ||
| const renderedContent = tabs.find(Tab).html(); | ||
ContributorAuthor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Checking for the Tab component instead of some arbitrary selector | ||
| expect(renderedContent).toEqual('<div>Tab 2 child</div>'); | ||
| }); | ||
| }); | ||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
React 16
<Fragment />polyfill -- gets rid of the wrapper<div />and allows the same behavior as before -- the extra div could break existing styles or make styling more difficult