Skip to content

Commit

Permalink
Refactor #1832 - For Calendar
Browse files Browse the repository at this point in the history
  • Loading branch information
mertsincan committed Mar 1, 2021
1 parent a06e650 commit 7371944
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
13 changes: 12 additions & 1 deletion src/components/calendar/Calendar.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { Ripple } from '../ripple/Ripple';
import UniqueComponentId from '../utils/UniqueComponentId';
import ConnectedOverlayScrollHandler from '../utils/ConnectedOverlayScrollHandler';
import { localeOption, localeOptions } from '../api/Locale';
import { PrimeEventBus } from '../utils/PrimeEventBus';

export class Calendar extends Component {

Expand Down Expand Up @@ -193,6 +194,7 @@ export class Calendar extends Component {
this.onYearDropdownChange = this.onYearDropdownChange.bind(this);
this.onTodayButtonClick = this.onTodayButtonClick.bind(this);
this.onClearButtonClick = this.onClearButtonClick.bind(this);
this.onPanelClick = this.onPanelClick.bind(this);
this.incrementHour = this.incrementHour.bind(this);
this.decrementHour = this.decrementHour.bind(this);
this.incrementMinute = this.incrementMinute.bind(this);
Expand Down Expand Up @@ -655,6 +657,15 @@ export class Calendar extends Component {
}
}

onPanelClick(event) {
if (!this.props.inline) {
PrimeEventBus.emit('overlay-click', {
originalEvent: event,
target: this.container
});
}
}

onTimePickerElementMouseDown(event, type, direction) {
if (!this.props.disabled) {
this.repeat(event, null, type, direction);
Expand Down Expand Up @@ -2963,7 +2974,7 @@ export class Calendar extends Component {
<span ref={(el) => this.container = el} id={this.id} className={className} style={this.props.style}>
{input}
{button}
<CalendarPanel ref={this.overlayRef} className={panelClassName} style={this.props.panelStyle} appendTo={this.props.appendTo}
<CalendarPanel ref={this.overlayRef} className={panelClassName} style={this.props.panelStyle} appendTo={this.props.appendTo} onClick={this.onPanelClick}
in={this.props.inline || this.state.overlayVisible} onEnter={this.onOverlayEnter} onEntered={this.onOverlayEntered} onExit={this.onOverlayExit}>
{datePicker}
{timePicker}
Expand Down
2 changes: 1 addition & 1 deletion src/components/calendar/CalendarPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class CalendarPanelComponent extends Component {
return (
<CSSTransition nodeRef={this.props.forwardRef} classNames="p-connected-overlay" in={this.props.in} timeout={{ enter: 120, exit: 100 }}
unmountOnExit onEnter={this.props.onEnter} onEntered={this.props.onEntered} onExit={this.props.onExit}>
<div ref={this.props.forwardRef} className={this.props.className} style={this.props.style}>
<div ref={this.props.forwardRef} className={this.props.className} style={this.props.style} onClick={this.props.onClick}>
{this.props.children}
</div>
</CSSTransition>
Expand Down

0 comments on commit 7371944

Please sign in to comment.