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: JavaScript error during ajax request #6641

Closed
JamieGHamilton opened this issue Dec 10, 2020 · 11 comments · Fixed by #6642
Closed

DatePicker: JavaScript error during ajax request #6641

JamieGHamilton opened this issue Dec 10, 2020 · 11 comments · Fixed by #6642
Assignees
Labels
8.0.19 🐞 defect Bug...Something isn't working
Milestone

Comments

@JamieGHamilton
Copy link

JamieGHamilton commented Dec 10, 2020

Describe the defect
The datePicker widget javascript contains the method "_destroy" which gets called during an ajax request when the component is rerendered. This destroy method calls 2 methods: this.restoreOverlayAppend() and this.onOverlayHide() - neither function seems to be defined anywhere and creates javascript errors.

Reproducer

Environment:

  • PF Version: 8.0
  • JSF + version: MyFaces 2.3.6
  • Affected browsers: ALL

To Reproduce
Steps to reproduce the behavior:

  1. Setup page with example xhtml below
  2. Monitor for javascript errors
  3. Click button "click for javascript error"
  4. See error: "this.restoreOverlayAppend is not a function"

Expected behavior
The datePicker destroy code should succeed without javascript errors.

Example XHTML

<h:form>
	<p:datePicker id="dp" />

	<p:commandButton id="ajaxButton"
	                 value="click for javascript error"
	                 process="dp"
	                 update="dp" />
</h:form>

Example Bean
no bean required

@JamieGHamilton JamieGHamilton added the 🐞 defect Bug...Something isn't working label Dec 10, 2020
@melloware
Copy link
Member

melloware commented Dec 10, 2020

I can't reproduce?
pf-6641.zip

Run mvn clean jetty:run -Pmyfaces23 and navigate to http://localhost:8080/primefaces-test/test.xhtml

@melloware melloware changed the title datePicker: Javascript error during ajax request DatePicker: JavaScript error during ajax request Dec 10, 2020
@JamieGHamilton
Copy link
Author

MyFaces will capture and hide this exception so you have to turn on debugging and pause on caught exceptions.
I can reproduce it with your example:
image

@melloware
Copy link
Member

I have my Chrome Console set to "preserve log" so any error thrown in the console remains and does not get cleared and I don't see it?
image

@JamieGHamilton
Copy link
Author

In chrome you need the stop sign to be blue and the checkbox "Pause on caught exceptions"
image

@melloware
Copy link
Member

I see it now thanks!

@melloware
Copy link
Member

OK can you add this MonkeyPatch to your JS code that loads after PF and see if its fixed.

if ($.prime && $.prime.datePicker) {
    $.prime.datePicker.prototype._destroy = function() {
        this.hideOverlay();
    };
}

melloware added a commit to melloware/primefaces that referenced this issue Dec 10, 2020
@melloware melloware self-assigned this Dec 10, 2020
@melloware melloware added this to the 9.0 milestone Dec 10, 2020
@melloware melloware linked a pull request Dec 10, 2020 that will close this issue
@JamieGHamilton
Copy link
Author

Yes...it's fixed!

@melloware
Copy link
Member

Thanks for reporting I would have never seen this if not for that break on JS error checkbox!

@JamieGHamilton
Copy link
Author

No problem.

@tibor-both-cc
Copy link

Can the fix patched also to the 8.x.x versions?

@melloware
Copy link
Member

Most likely not in 8.0 as the fix is already included in 10.0.0 and 11.0.0 and you have the MonkeyPatch you can use above for 8.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
8.0.19 🐞 defect Bug...Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants