Page 1 of 2

Spark menu not working with PF 6.2

Posted: 03 Mar 2018, 17:13
by Dsleeper
Hi,

The Spark menus are not working after I have upgraded my project to Primefaces 6.2. The topmenu is rendered, but no dropdown elements are triggered on mouse click.

Is this something that can be easily fixed in the "layout.js" of Spark? I really would like to use the new 6.2 support for primefaces.MOVE_SCRIPTS_TO_BOTTOM :)

Chrome console log:
layout.js.jsf?ln=spark-layout:19 Uncaught TypeError: topmenuItems.size is not a function
at c.init (http://localhost:8080/javax.faces.resou ... yout:19:37)
at c.e.(anonymous function) [as init] (http://localhost:8080/javax.faces.resou ... =6.2:5:335)
at new c (http://localhost:8080/javax.faces.resou ... =6.2:5:437)
at Object.createWidget (http://localhost:8080/javax.faces.resou ... 6.2:1:4964)
at Object.cw (http://localhost:8080/javax.faces.resou ... 6.2:1:4785)
at http://localhost:8080/forum/topic/523:186:4
init @ layout.js.jsf?ln=spark-layout:19
e.(anonymous function) @ core.js.jsf?ln=primefaces&v=6.2:5
c @ core.js.jsf?ln=primefaces&v=6.2:5
createWidget @ core.js.jsf?ln=primefaces&v=6.2:1
cw @ core.js.jsf?ln=primefaces&v=6.2:1
(anonymous) @ 523:186

Re: Spark menu not working with PF 6.2

Posted: 03 Mar 2018, 20:53
by Dsleeper
Fixed this by doing the following:
1. Open your Spark layout.js (\src\main\webapp\resources\spark-layout\js\
2. Change line 19 from:

Code: Select all

        for(var i=0; i<topmenuItems.size(); i++) {
to

Code: Select all

        for(var i=0; i<topmenuItems.length; i++) {
I guess this error occurred because PF 6.2 upgraded to the latest JQuery implementation. In the latest JQuery ".size()" has removed in favor for ".length"

If possible this should probably be put into a Spark patch?

Re: Spark menu not working with PF 6.2

Posted: 07 Mar 2018, 08:41
by mert.sincan
Thanks a lot for the PR, please use the following code for now;

Code: Select all

/** 
 * PrimeFaces Spark Layout
 */
PrimeFaces.widget.Spark = PrimeFaces.widget.Spark.extend({
  
    init: function(cfg) {
        this._super(cfg);
        this.menubar = $('#layout-menu');
        this.topmenu = $('#layout-topbar-menu');
        this.menumask = $('#menu-mask');
        this.focusedLink = null;
        this.focusedTopLink = null;
        this.layoutMenuClick = false;
        this.topbarMenuClick = false;
        
        // for keyboard navigation
        this.topmenu.attr('tabindex', '0');
        var topmenuItems = this.topmenu.find('a');
        for(var i=0; i<topmenuItems.length; i++) {
            topmenuItems.eq(i).attr('tabindex', '-1');
        } 
        
        this.bindEvents();
        this.bindKeyEvents();
    }
});
If possible this should probably be put into a Spark patch?
Could you please send an email to contact at primetek.com.tr?

Re: Spark menu not working with PF 6.2

Posted: 07 Mar 2018, 09:17
by Dsleeper
Email sent! :geek:

Re: Spark menu not working with PF 6.2

Posted: 12 Mar 2018, 14:23
by mert.sincan
Thanks a lot!

Re: Spark menu not working with PF 6.2

Posted: 15 Mar 2018, 16:07
by jcpearce2005
This had been stumping me for a bit.

Thank you for the fix!

Re: Spark menu not working with PF 6.2

Posted: 26 Mar 2018, 13:29
by mert.sincan
Thanks a lot for the update! ;)

Re: Spark menu not working with PF 6.2

Posted: 19 Apr 2018, 15:57
by asesovici
Hi @aragorn, I am having the same problem after upgrading to PrimeFaces 6.2.

I am currently using Spark Layout v2.1.1. I see on PrimeStore that v2.1.2 is available and it appears that its layout.js is using the new function you mentioned. Should I try to use v2.1.2 instead? Is it fully compatible with PF 6.2?
If so, then what I don't understand is why the Migration Update from v.2.1.1 to 2.1.2 doesn't mention anything about updating the layout.js file.

Thank you in advance.

Re: Spark menu not working with PF 6.2

Posted: 23 Apr 2018, 19:54
by asesovici
It appears I was wrong. The 2.1.2 version is still using the old jQuery size() method. For the moment, I manually patched the layout.js file but I would like to make sure that this is the only compatibility issue.

Can someone confirm this? Why isn't there a PrimeFaces 6.2 compatible version of the Spark layout released yet?

Re: Spark menu not working with PF 6.2

Posted: 25 Apr 2018, 09:11
by mert.sincan
We plan to release new Spark version in this week or next week.

Regards,