Skip to content

Commit

Permalink
fix(kit): InputDate fix mobile calendar (#104)
Browse files Browse the repository at this point in the history
Closes #100
  • Loading branch information
waterplea authored Jan 15, 2021
1 parent 3410cc3 commit 0fd20e5
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -228,17 +228,12 @@ export class TuiInputDateRangeComponent
}

onClick() {
if (!this.computedMobile) {
if (!this.isMobile || !this.mobileCalendar) {
this.toggle();
}
}

onMobileMouseDown(event: TouchEvent) {
if (!this.mobileCalendar) {
return;
}

event.stopPropagation();
this.dialogService
.open<TuiDayRange>(
new PolymorpheusComponent(this.mobileCalendar, this.injector),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
automation-id="tui-input-date-range__icon"
class="icon"
[src]="calendarIcon"
(touchstart)="onMobileMouseDown($event)"
(click.prevent)="onClick()"
></tui-svg>
</ng-template>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ export class TuiInputDateTimeComponent
return !this.computedDisabled && !this.readOnly;
}

onMouseDown() {
onClick() {
this.open = !this.open;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
(valueChange)="onValueChange($event)"
(hoveredChange)="onHovered($event)"
(focusedChange)="onFocused($event)"
(mousedown)="onMouseDown()"
(click.prevent)="onClick()"
>
<ng-content></ng-content>
</tui-primitive-textfield>
Expand Down
9 changes: 2 additions & 7 deletions projects/kit/components/input-date/input-date.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,18 +195,13 @@ export class TuiInputDateComponent
this.open = false;
}

onMouseDown() {
if (!this.computedMobile) {
onClick() {
if (!this.isMobile || !this.mobileCalendar) {
this.open = !this.open;
}
}

onMobileMouseDown(event: TouchEvent) {
if (!this.mobileCalendar) {
return;
}

event.stopPropagation();
this.dialogService
.open<TuiDay>(new PolymorpheusComponent(this.mobileCalendar, this.injector), {
size: 'fullscreen',
Expand Down
4 changes: 2 additions & 2 deletions projects/kit/components/input-date/input-date.template.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
(valueChange)="onValueChange($event)"
(hoveredChange)="onHovered($event)"
(focusedChange)="onFocused($event)"
(mousedown)="onMouseDown()"
(click.prevent)="onClick()"
>
<ng-content></ng-content>
</tui-primitive-textfield>
Expand All @@ -32,7 +32,7 @@
automation-id="tui-input-date-range__icon"
class="icon"
[src]="calendarIcon"
(touchstart)="onMobileMouseDown($event)"
(click.prevent)="onClick()"
></tui-svg>
</ng-template>

Expand Down

0 comments on commit 0fd20e5

Please sign in to comment.