Skip to content

Commit e616001

Browse files
committed
Fix confirm dialog provider
1 parent 61b8ea6 commit e616001

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

components/dash-core-components/src/components/ConfirmDialogProvider.react.js

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,19 @@ export default class ConfirmDialogProvider extends React.Component {
2020
render() {
2121
const {displayed, id, setProps, children} = this.props;
2222

23+
// Will lose the previous onClick of the child
24+
const wrapClick = child =>
25+
React.cloneElement(child, {
26+
extras: {
27+
onClick: () => setProps({displayed: true}),
28+
},
29+
});
30+
2331
return (
24-
<LoadingElement
25-
id={id}
26-
onClick={() => setProps({displayed: !displayed})}
27-
>
28-
{children}
32+
<LoadingElement id={id}>
33+
{Array.isArray(children)
34+
? children.map(wrapClick)
35+
: wrapClick(children)}
2936
<ConfirmDialog {...this.props} displayed={displayed} />
3037
</LoadingElement>
3138
);

0 commit comments

Comments
 (0)