Skip to content

Commit

Permalink
Refactor #1951 - For OverlayPanel
Browse files Browse the repository at this point in the history
  • Loading branch information
mertsincan committed Apr 12, 2021
1 parent ece6d7a commit 0c5d6b9
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/components/overlaypanel/OverlayPanel.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ interface OverlayPanelProps {
ariaCloseLabel?: string;
breakpoints?: Breakpoints;
transitionOptions?: object;
onShow?(): void;
onHide?(): void;
}

Expand Down
10 changes: 6 additions & 4 deletions src/components/overlaypanel/OverlayPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export class OverlayPanel extends Component {
breakpoints: null,
ariaCloseLabel: 'close',
transitionOptions: null,
onShow: null,
onHide: null
}

Expand All @@ -35,6 +36,7 @@ export class OverlayPanel extends Component {
breakpoints: PropTypes.object,
ariaCloseLabel: PropTypes.string,
transitionOptions: PropTypes.object,
onShow: PropTypes.func,
onHide: PropTypes.func
}

Expand Down Expand Up @@ -173,10 +175,6 @@ export class OverlayPanel extends Component {
hide() {
this.setState({ visible: false }, () => {
OverlayEventBus.off('overlay-click');

if (this.props.onHide) {
this.props.onHide();
}
});
}

Expand All @@ -190,6 +188,8 @@ export class OverlayPanel extends Component {
this.bindDocumentClickListener();
this.bindScrollListener();
this.bindResizeListener();

this.props.onShow && this.props.onShow();
}

onExit() {
Expand All @@ -200,6 +200,8 @@ export class OverlayPanel extends Component {

onExited() {
ZIndexUtils.clear(this.overlayRef.current);

this.props.onHide && this.props.onHide();
}

align() {
Expand Down
7 changes: 6 additions & 1 deletion src/showcase/overlaypanel/OverlayPanelDoc.js
Original file line number Diff line number Diff line change
Expand Up @@ -373,10 +373,15 @@ import { OverlayPanel } from 'primereact/overlaypanel';
</tr>
</thead>
<tbody>
<tr>
<td>onShow</td>
<td>-</td>
<td>Callback to invoke when overlay becomes visible.</td>
</tr>
<tr>
<td>onHide</td>
<td>-</td>
<td>Callback to invoke when overlay gets hidden.</td>
<td>Callback to invoke when overlay becomes hidden.</td>
</tr>
</tbody>
</table>
Expand Down

0 comments on commit 0c5d6b9

Please sign in to comment.