Skip to content

Commit

Permalink
Refactor #1917 - For Fieldset
Browse files Browse the repository at this point in the history
  • Loading branch information
mertsincan committed Apr 12, 2021
1 parent f30e86f commit 14486c5
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/components/fieldset/Fieldset.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ interface FieldsetProps {
style?: object;
toggleable?: boolean;
collapsed?: boolean;
transitionOptions?: object;
onExpand?(event: React.MouseEvent<HTMLElement>): void;
onCollapse?(event: React.MouseEvent<HTMLElement>): void;
onToggle?(e: ToggleParams): void;
Expand Down
6 changes: 4 additions & 2 deletions src/components/fieldset/Fieldset.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { classNames } from '../utils/ClassNames';
import UniqueComponentId from '../utils/UniqueComponentId';
import { CSSTransition } from 'react-transition-group';
import { CSSTransition } from '../transition/CSSTransition';
import { Ripple } from '../ripple/Ripple';

export class Fieldset extends Component {
Expand All @@ -14,6 +14,7 @@ export class Fieldset extends Component {
style: null,
toggleable: null,
collapsed: null,
transitionOptions: null,
onExpand: null,
onCollapse: null,
onToggle: null,
Expand All @@ -27,6 +28,7 @@ export class Fieldset extends Component {
style: PropTypes.object,
toggleable: PropTypes.bool,
collapsed: PropTypes.bool,
transitionOptions: PropTypes.object,
onExpand: PropTypes.func,
onCollapse: PropTypes.func,
onToggle: PropTypes.func,
Expand Down Expand Up @@ -106,7 +108,7 @@ export class Fieldset extends Component {
const id = this.state.id + '_content';

return (
<CSSTransition nodeRef={this.contentRef} classNames="p-toggleable-content" timeout={{ enter: 1000, exit: 450 }} in={!collapsed} unmountOnExit>
<CSSTransition nodeRef={this.contentRef} classNames="p-toggleable-content" timeout={{ enter: 1000, exit: 450 }} in={!collapsed} unmountOnExit options={this.props.transitionOptions}>
<div ref={this.contentRef} id={id} className="p-toggleable-content" aria-hidden={collapsed} role="region" aria-labelledby={this.state.id + '_header'}>
<div className="p-fieldset-content">
{this.props.children}
Expand Down
6 changes: 6 additions & 0 deletions src/showcase/fieldset/FieldsetDoc.js
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,12 @@ import { Fieldset } from 'primereact/fieldset';
<td>false</td>
<td>Defines the default visibility state of the content.</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 14486c5

Please sign in to comment.