Skip to content

Commit

Permalink
Refactor #1917 - For SplitButton
Browse files Browse the repository at this point in the history
  • Loading branch information
mertsincan committed Apr 12, 2021
1 parent 57d69db commit 44ebc12
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/components/splitbutton/SplitButton.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ interface SplitButtonProps {
tooltip?: string;
tooltipOptions?: TooltipOptions;
buttonTemplate?: ButtonTemplateType;
transitionOptions?: object;
onClick?(event: React.MouseEvent<HTMLElement>): void;
}

Expand Down
5 changes: 4 additions & 1 deletion src/components/splitbutton/SplitButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export class SplitButton extends Component {
tooltip: null,
tooltipOptions: null,
buttonTemplate: null,
transitionOptions: null,
onClick: null
}

Expand All @@ -47,6 +48,7 @@ export class SplitButton extends Component {
tooltip: PropTypes.string,
tooltipOptions: PropTypes.object,
buttonTemplate: PropTypes.any,
transitionOptions: PropTypes.object,
onClick: PropTypes.func
}

Expand Down Expand Up @@ -247,7 +249,8 @@ export class SplitButton extends Component {
aria-expanded={this.state.overlayVisible} aria-haspopup aria-owns={this.state.id + '_overlay'} />
<SplitButtonPanel ref={this.overlayRef} appendTo={this.props.appendTo} id={this.state.id + '_overlay'}
menuStyle={this.props.menuStyle} menuClassName={this.props.menuClassName} onClick={this.onPanelClick}
in={this.state.overlayVisible} onEnter={this.onOverlayEnter} onEntered={this.onOverlayEntered} onExit={this.onOverlayExit} onExited={this.onOverlayExited}>
in={this.state.overlayVisible} onEnter={this.onOverlayEnter} onEntered={this.onOverlayEntered} onExit={this.onOverlayExit} onExited={this.onOverlayExited}
transitionOptions={this.props.transitionOptions}>
{items}
</SplitButtonPanel>
</div>
Expand Down
4 changes: 2 additions & 2 deletions src/components/splitbutton/SplitButtonPanel.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { classNames } from '../utils/ClassNames';
import { CSSTransition } from 'react-transition-group';
import { CSSTransition } from '../transition/CSSTransition';
import { Portal } from '../portal/Portal';

class SplitButtonPanelComponent extends Component {
Expand All @@ -26,7 +26,7 @@ class SplitButtonPanelComponent extends Component {
let className = classNames('p-menu p-menu-overlay p-component', this.props.menuClassName);

return (
<CSSTransition nodeRef={this.props.forwardRef} classNames="p-connected-overlay" in={this.props.in} timeout={{ enter: 120, exit: 100 }}
<CSSTransition nodeRef={this.props.forwardRef} classNames="p-connected-overlay" in={this.props.in} timeout={{ enter: 120, exit: 100 }} options={this.props.transitionOptions}
unmountOnExit onEnter={this.props.onEnter} onEntered={this.props.onEntered} onExit={this.props.onExit} onExited={this.props.onExited}>
<div ref={this.props.forwardRef} className={className} style={this.props.menuStyle} id={this.props.id} onClick={this.onClick}>
<ul className="p-menu-list p-reset" role="menu">
Expand Down
6 changes: 6 additions & 0 deletions src/showcase/splitbutton/SplitButtonDoc.js
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,12 @@ export const SplitButtonDemo = () => {
<td>null</td>
<td>Template of the default button.</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 44ebc12

Please sign in to comment.