Skip to content

Commit

Permalink
fix(datepicker): prevent outside click to close datepicker on navigation
Browse files Browse the repository at this point in the history
  • Loading branch information
valorkin committed Aug 18, 2017
1 parent d7f9a2a commit 6472b6f
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ import { Component } from '@angular/core';
templateUrl: './date-picker-popup.html'
})
export class DemoDatePickerPopupComponent {
public bsValue: any = new Date(2017, 7, 4);
public bsValue: any ;
public bsRangeValue: any = [new Date(2017, 7, 4), new Date(2017, 7, 20)];
}
7 changes: 5 additions & 2 deletions src/datepicker/themes/bs/bs-datepicker-container.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import 'rxjs/add/operator/filter';
providers: [BsDatepickerStore],
template: `
<bs-datepicker-view
*ngIf="months && options"
[months]="months"
[options]="options"
(onNavigate)="navigateTo($event)"
Expand All @@ -21,6 +20,7 @@ import 'rxjs/add/operator/filter';
></bs-datepicker-view>
`,
host: {
'(click)': '_stopPropagation($event)',
style: 'position: absolute; display: block;'
}
})
Expand Down Expand Up @@ -52,7 +52,6 @@ export class BsDatepickerContainerComponent {
showWeekNumbers: true
}));


// on selected date change
this._bsDatepickerStore.select(state => state.selectedDate)
.subscribe(date => this.valueChange.emit(date));
Expand Down Expand Up @@ -109,4 +108,8 @@ export class BsDatepickerContainerComponent {
}
this._bsDatepickerStore.dispatch(this._actions.select(day.date));
}

_stopPropagation(event: any): void {
event.stopPropagation();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import { BsNavigationEvent, MonthViewModel, TimeUnit } from '../../models/index'
[style.visibility]="month.hideLeftArrow ? 'hidden' : 'visible'"
(click)="navTo({month: -1})"><span>&lsaquo;</span>
</button>
<button class="current" (click)="viewMode('months')"><span>{{month.monthTitle}}</span>
<button class="current"><span>{{ month.monthTitle }}</span>
</button>
<button class="current" (click)="viewMode('years')"><span>{{month.yearTitle}}</span>
<button class="current"><span>{{ month.yearTitle }}</span>
</button>
<button class="next"
[style.visibility]="month.hideRightArrow ? 'hidden' : 'visible'"
Expand All @@ -26,6 +26,4 @@ export class BsDatepickerNavigationViewComponent {
navTo(step: TimeUnit): void {
this.onNavigate.emit({step});
}

viewMode(v: string) {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import 'rxjs/add/operator/filter';
></bs-datepicker-view>
`,
host: {
'(click)': '_stopPropagation($event)',
style: 'position: absolute; display: block;'
}
})
Expand Down Expand Up @@ -130,4 +131,8 @@ export class BsDaterangepickerContainerComponent implements OnInit {
this._rangeStack = [];
}
}

_stopPropagation(event: any): void {
event.stopPropagation();
}
}

0 comments on commit 6472b6f

Please sign in to comment.