Declined
Last Updated: 22 May 2023 11:02 by ADMIN
Alice
Created on: 15 May 2023 15:25
Category: Kendo UI for Angular
Type: Bug Report
0
[DateInputs] others fillMode not working if component is displayed conditionally

Reproduce the bug with

import { Component } from "@angular/core";

@Component({
  selector: "my-app",
  template: `
    <button (click)="show = !show">Show/hide</button>
    <ng-container *ngIf="show">
      <div class="example-config">
        Selected value is: {{ value | kendoDate: "MM/dd/yyyy" }}
      </div>
      <div class="example-wrapper" style="min-height: 400px">
        <p>Select a date:</p>
        <kendo-datepicker
          [(value)]="value"
          fillMode="outline"
        ></kendo-datepicker>
        <p>
          (use Alt+↓ to open the calendar, ← and → to navigate, ↑ to increment
          and ↓ to decrement the value)
        </p>
      </div>
    </ng-container>
  `,
  styles: [
    `
      kendo-datepicker {
        width: 170px;
      }
    `
  ]
})
export class AppComponent {
  public show = false;
  public value: Date = new Date(2000, 2, 10);
}

error displayed:

"TypeError: Cannot read properties of undefined (reading 'nativeElement')
    at set fillMode [as fillMode] (progress-kendo-angular-dateinputs.mjs:9186:53)
    at Object.ngOnChangesSetInp"

in file
node_modules/@progress/kendo-angular-dateinputs/fesm2020/progress-kendo-angular-dateinputs.mjs

at


 /**
     * Sets the fillMode of the component.
     *
     * The possible values are:
     * * `solid` (Default)
     * * `flat`
     * * `outline`
     * * `none`
     *
     */
    set fillMode(fillMode) {
        this.renderer.removeClass(this.wrapper.nativeElement, getFillModeClass('input', this.fillMode));
        this.renderer.removeClass(this.toggleButton.nativeElement, getFillModeClass('button', this.fillMode));
        this.renderer.removeClass(this.toggleButton.nativeElement, `k-button-${this.fillMode}-base`);
        const newFillMode = fillMode ? fillMode : DEFAULT_FILL_MODE;
        if (newFillMode !== 'none') {
            this.renderer.addClass(this.toggleButton.nativeElement, getFillModeClass('button', newFillMode));
            this.renderer.addClass(this.toggleButton.nativeElement, `k-button-${newFillMode}-base`);
            this.renderer.addClass(this.wrapper.nativeElement, getFillModeClass('input', newFillMode));
        }
       

It works when the code changes in

import { AfterViewInit, Component } from "@angular/core";

@Component({
  selector: "my-app",
  template: `
    <button (click)="show = !show">Show/hide</button>
    <ng-container *ngIf="show">
      <div class="example-config">
        Selected value is: {{ value | kendoDate: "MM/dd/yyyy" }}
      </div>
      <div class="example-wrapper" style="min-height: 400px">
        <p>Select a date:</p>
        <kendo-datepicker
          [(value)]="value"
          [fillMode]="fillMode"
        ></kendo-datepicker>
        <p>
          (use Alt+↓ to open the calendar, ← and → to navigate, ↑ to increment
          and ↓ to decrement the value)
        </p>
      </div>
    </ng-container>
  `,
  styles: [
    `
      kendo-datepicker {
        width: 170px;
      }
    `
  ]
})
export class AppComponent implements AfterViewInit {
  public show = false;
  public value: Date = new Date(2000, 2, 10);

  public fillMode = "solid";

  ngAfterViewInit() {
    Promise.resolve().then(() => (this.fillMode = "outline"));
  }
}

It only appears in DateInputs Components, other Inputs work well
1 comment
ADMIN
Martin
Posted on: 22 May 2023 11:02

Hi Alice,

Thank you for the provided feedback.

There is a difference between date input controls and input controls in terms of how the fillMode property is applied. That is why an error is thrown only for the data inputs.

Generally, setting the fillMode property directly to 'outline' is an incorrect configuration, since the fillMode expects a value from type DateInputFillMode rather than just a string (this is valid for the input controls where the type is InputFillMode).

The following configuration isn't correct as well, as it would throw an error similar to 'Type 'string' is not assignable to type 'DateInputFillMode'.

[fillMode]="fillMode"
public fillMode = "solid";

However, if you define a type to the fillMode variable, the changes are applied as expected:

public fillMode: DateInputFillMode = 'solid'

https://stackblitz.com/edit/angular-jkysga

Having said that the reported behavior cannot be considered as a bug, as the property is applied successfully if setting up in accordance with the official product documentation.

Regards,
Martin
Progress Telerik

Stay tuned by visiting our public roadmap and feedback portal pages! Or perhaps, if you are new to our Kendo family, check out our getting started resources