Skip to content

Commit

Permalink
Refactor #1917 - For ConfirmPopup
Browse files Browse the repository at this point in the history
  • Loading branch information
mertsincan committed Apr 12, 2021
1 parent 88d526e commit a2d80d2
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/components/confirmpopup/ConfirmPopup.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ interface ConfirmPopupProps {
appendTo?: HTMLElement;
dismissable?: boolean;
footer?: TemplateType;
transitionOptions?: object;
onHide?(result: string): void;
accept?(): void;
reject?(): void;
Expand Down
10 changes: 6 additions & 4 deletions src/components/confirmpopup/ConfirmPopup.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import ReactDOM from 'react-dom';
import PropTypes from 'prop-types';
import { classNames } from '../utils/ClassNames';
import { Button } from '../button/Button';
import { CSSTransition } from 'react-transition-group';
import { CSSTransition } from '../transition/CSSTransition';
import ConnectedOverlayScrollHandler from '../utils/ConnectedOverlayScrollHandler';
import DomHandler from '../utils/DomHandler';
import ObjectUtils from '../utils/ObjectUtils';
Expand Down Expand Up @@ -66,7 +66,8 @@ export class ConfirmPopup extends Component {
footer: null,
onHide: null,
accept: null,
reject: null
reject: null,
transitionOptions: null
}

static propTypes = {
Expand All @@ -87,7 +88,8 @@ export class ConfirmPopup extends Component {
footer: PropTypes.any,
onHide: PropTypes.func,
accept: PropTypes.func,
reject: PropTypes.func
reject: PropTypes.func,
transitionOptions: PropTypes.object
}

constructor(props) {
Expand Down Expand Up @@ -331,7 +333,7 @@ export class ConfirmPopup extends Component {
const footer = this.renderFooter();

return (
<CSSTransition nodeRef={this.overlayRef} classNames="p-connected-overlay" in={this.state.visible} timeout={{ enter: 120, exit: 100 }}
<CSSTransition nodeRef={this.overlayRef} classNames="p-connected-overlay" in={this.state.visible} timeout={{ enter: 120, exit: 100 }} options={this.props.transitionOptions}
unmountOnExit onEnter={this.onEnter} onEntered={this.onEntered} onExit={this.onExit} onExited={this.onExited}>
<div ref={this.overlayRef} id={this.props.id} className={className} style={this.props.style} onClick={this.onPanelClick}>
{content}
Expand Down
6 changes: 6 additions & 0 deletions src/showcase/confirmpopup/ConfirmPopupDoc.js
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,12 @@ const confirm = (event) => {
<td>null</td>
<td>Style class of the element.</td>
</tr>
<tr>
<td>transitionOptions</td>
<td>object</td>
<td>null</td>
<td>The properties of <a href="https://reactcommunity.org/react-transition-group/css-transition" rel="noopener noreferrer" target="_blank">CSSTransition</a> can be customized, except for "nodeRef" and "in" properties.</td>
</tr>
</tbody>
</table>
</div>
Expand Down

0 comments on commit a2d80d2

Please sign in to comment.