Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DatePicker: "Cannot read properties of null" error when clicking on next/previous month button (18.0.0-beta.3) #16590

Closed
flortsch opened this issue Oct 19, 2024 · 7 comments · Fixed by #16675
Labels
Type: Bug Issue contains a bug related to a specific component. Something about the component is not working
Milestone

Comments

@flortsch
Copy link

Describe the bug

client:489 [vite] connecting...
client:608 [vite] connected.
core.mjs:30062 Angular is running in development mode.
zone.js:1201 [Violation] 'focus' handler took 302ms
zone.js:1201 [Violation] 'focus' handler took 258ms
zone.js:1201 [Violation] 'focus' handler took 253ms
zone.js:1201 [Violation] 'click' handler took 266ms
global-error-handler.ts:10 TypeError: Cannot read properties of null (reading 'focus')
    at _DatePicker.updateFocus (primeng-datepicker.mjs:3828:217)
    at primeng-datepicker.mjs:2527:47
    at _ZoneDelegate.invoke (zone.js:369:28)
    at Object.onInvoke (core.mjs:7041:25)
    at _ZoneDelegate.invoke (zone.js:368:34)
    at _ZoneImpl.run (zone.js:111:43)
    at zone.js:2538:40
    at _ZoneDelegate.invokeTask (zone.js:402:33)
    at core.mjs:6710:49
    at AsyncStackTaggingZoneSpec.onInvokeTask (core.mjs:6710:30)
handleError @ global-error-handler.ts:10
next @ core.mjs:33150
ConsumerObserver2.next @ Subscriber.js:90
Subscriber2._next @ Subscriber.js:59
Subscriber2.next @ Subscriber.js:32
(anonymous) @ Subject.js:41
errorContext @ errorContext.js:23
Subject2.next @ Subject.js:31
emit @ core.mjs:6583
(anonymous) @ core.mjs:7075
invoke @ zone.js:369
run @ zone.js:111
runOutsideAngular @ core.mjs:6937
onHandleError @ core.mjs:7075
handleError @ zone.js:373
runGuarded @ zone.js:124
api.microtaskDrainDone @ zone.js:2325
drainMicroTaskQueue @ zone.js:588
invokeTask @ zone.js:487
invokeTask @ zone.js:1138
globalCallback @ zone.js:1169
globalZoneAwareCallback @ zone.js:1202
Show 21 more frames
Show less
zone.js:1201 [Violation] 'click' handler took 289ms

Environment

<p-datePicker
        [dateFormat]="dateFormat"
        [ngClass]="{ 'opacity-50': readonly }"
        [showOnFocus]="!readonly"
        [id]="field.name"
        [formControlName]="field.name"
        [showIcon]="!readonly"
        [showButtonBar]="true"
        [readonlyInput]="true"
        [minDate]="minDate"
        [maxDate]="maxDate"
        dataType="string"
      >
</p-datePicker>

Reproducer

No response

Angular version

18.2.3

PrimeNG version

18.0.0-beta.3

Build / Runtime

Angular CLI App

Language

TypeScript

Node version (for AoT issues node --version)

18.20.4

Browser(s)

No response

Steps to reproduce the behavior

No response

Expected behavior

No response

@flortsch flortsch added the Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible label Oct 19, 2024
@flortsch flortsch changed the title DatePicker: Bug when clicking on next/previous month button (18.0.0-beta.3) DatePicker: "Cannot read properties of null" error when clicking on next/previous month button (18.0.0-beta.3) Oct 19, 2024
@mplgn
Copy link

mplgn commented Oct 21, 2024

Continuation of #16436, which was closed and thought to be fixed for beta-3.

@cetincakiroglu cetincakiroglu added this to the 18.0.0-rc.1 milestone Oct 26, 2024
@jonbeech86
Copy link

I can confirm I am still getting this on beta-3.
I see its also happening on the docs too but not sure what version that is running, I assume beta-3: https://v18.primeng.org/datepicker

@Dayonel
Copy link
Contributor

Dayonel commented Oct 31, 2024

Hi, I can confirm this bug is still happening in beta-3 and also in your docs.

@Dayonel
Copy link
Contributor

Dayonel commented Oct 31, 2024

Error is gone if chevron buttons next & prev

have a css class p-datepicker-next instead of p-datepicker-next-button (notice -button)

or

js checks for '.p-datepicker-prev-button').focus() instead of '.p-datepicker-prev').focus() (notice -button)

image

Same for -next code.

@Dayonel
Copy link
Contributor

Dayonel commented Oct 31, 2024

This temporary solution fixes the bug:


        <p-datepicker formControlName="date" appendTo="body">

          <!-- TODO: Remove this on beta-4 -->
          <ng-template pTemplate="footer">
            <p-button class="p-datepicker-prev hidden">Previous</p-button>
            <p-button class="p-datepicker-next hidden">Next</p-button>
          </ng-template>
          <!-- end TODO -->

        </p-datepicker>

Dayonel added a commit to Dayonel/primeng that referenced this issue Oct 31, 2024
Dayonel added a commit to Dayonel/primeng that referenced this issue Oct 31, 2024
@Dayonel
Copy link
Contributor

Dayonel commented Oct 31, 2024

Fixed in PR: 16675

@mertsincan mertsincan added Type: Bug Issue contains a bug related to a specific component. Something about the component is not working and removed Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible labels Nov 18, 2024
@mertsincan mertsincan linked a pull request Nov 18, 2024 that will close this issue
Dayonel added a commit to Dayonel/primeng that referenced this issue Nov 18, 2024
@mertsincan mertsincan removed this from PrimeNG Nov 20, 2024
@cetincakiroglu cetincakiroglu added the Status: Pending Review Issue or pull request is being reviewed by Core Team label Nov 21, 2024
@mertsincan mertsincan removed the Status: Pending Review Issue or pull request is being reviewed by Core Team label Nov 26, 2024
mertsincan pushed a commit that referenced this issue Nov 26, 2024
* fix(v18): Datepicker focus error #16590

* fix(v18): Datepicker focus error #16590

---------

Co-authored-by: Nestor <[email protected]>
@mertsincan
Copy link
Member

Fixed in #16675

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Issue contains a bug related to a specific component. Something about the component is not working
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

6 participants