question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

autoComplete: Serenity theme layout.js bug on removing item

See original GitHub issue

Describe the defect Remove an item from the p:autoComplete multiple select is not working. It throws an error:

components.js.xhtml?ln=primefaces&v=10.0.0&e=10.0.0:3 Uncaught TypeError: c.attr is not a function
    at c.removeItem (components.js.xhtml?ln=primefaces&v=10.0.0&e=10.0.0:3)
    at HTMLSpanElement.<anonymous> (layout.js.xhtml?ln=serenity-layout:818)
    at HTMLUListElement.dispatch (jquery.js.xhtml?ln=primefaces&v=10.0.0&e=10.0.0:2)
    at HTMLUListElement.v.handle (jquery.js.xhtml?ln=primefaces&v=10.0.0&e=10.0.0:2)

I have to manually change the serenity-layout/layout.js with temporary fix shown in the codes below.

if(PrimeFaces.widget.AutoComplete) {
    PrimeFaces.widget.AutoComplete.prototype.setupMultipleMode = function() {
        var $this = this;
        this.multiItemContainer = this.jq.children('ul');
        this.inputContainer = this.multiItemContainer.children('.ui-autocomplete-input-token');

        this.multiItemContainer.hover(function() {
                $(this).addClass('ui-state-hover');
            },
            function() {
                $(this).removeClass('ui-state-hover');
            }
        ).click(function() {
            $this.input.focus();
        });

        //delegate events to container
        this.input.focus(function() {
            $this.multiItemContainer.addClass('ui-state-focus');
            $this.jq.addClass('md-inputwrapper-focus');
        }).blur(function(e) {
            $this.multiItemContainer.removeClass('ui-state-focus');
            $this.jq.removeClass('md-inputwrapper-focus').addClass('md-inputwrapper-filled');
            
            setTimeout(function() {
                if($this.hinput.children().length == 0 && !$this.multiItemContainer.hasClass('ui-state-focus')) {
                    $this.jq.removeClass('md-inputwrapper-filled');
                }
            }, 150); 
        });

        var closeSelector = '> li.ui-autocomplete-token > .ui-autocomplete-token-icon';
        this.multiItemContainer.off('click', closeSelector).on('click', closeSelector, null, function(event) {
            if($this.multiItemContainer.children('li.ui-autocomplete-token').length === $this.cfg.selectLimit) {
                if(PrimeFaces.isIE(8)) {
                    $this.input.val('');
                }
                $this.input.css('display', 'inline');
                $this.enableDropdown();
            }
            //$this.removeItem(event, $(this).parent());  //<---- Original Serenity code which cause the error
            $this.removeItem($(this).parent());  //<-- temporary fix
        });
    };
};

Environment:

  • PF Version: 10.0.0
  • JSF + version: Mojarra 2.3.9
  • Affected browsers: ALL

To Reproduce

  1. Download serenity-2.1.1.zip from PrimeStore and add Serenity theme to project
  2. Create autoComplete like below example

Example XHTML

<p:autoComplete id="organization-list" value="#{orgView.organizations}" completeMethod="#{orgView.onOrgSuggestionsFired}"
                             var="institution" itemValue="#{institution}" itemLabel="#{institution.granteeName}" converter="#{orgAutoCompleteConverter}" 
                             emptyMessage="No results" multiple="true" forceSelection="true">
    <p:ajax event="itemSelect" listener="#{orgView.onOrgSelect}" update="growl"/>
    <p:ajax event="itemUnselect" listener="#{orgView.onOrgUnselect}" update="growl"/>
</p:autoComplete>

Example Bean

@Named
@ViewScoped
public class OrgView implements Serializable {
    ...
    public void onOrgSelect(SelectEvent<Institution> event) {
        organizations.add(event.getObject());
    }
    public void onInstitutionUnselect(UnselectEvent<Institution> event) {
        organizations.remove(event.getObject());
    }
}

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
sqorescommented, Jul 7, 2021

I updated Serenity with new material theme which one is developed from scratch. Please wait a week for release. We are working on some missing features.

1reaction
mellowarecommented, Jul 7, 2021

According the WIKI Serenity has not been updated for PF10 yet: https://github.com/primefaces/primefaces/wiki/Updates-Of-Premium-Templates-For-PrimeFaces-X

Read more comments on GitHub >

github_iconTop Results From Across the Web

Serenity/CHANGELOG.md at master - GitHub
As Serenity.Data used 2.1.0 of Microsoft.Data.SqlClient, only sergen was affected by this issue, not StartSharp or Serene apps. Please see the linked doc, ......
Read more >
Serene - Visual Studio Marketplace
Serene is a starter template to build Serenity applications. ... to reorganize existing navigation items to groups / sections (StartSharp pro theme) ...
Read more >
Autocomplete plugin does not work in blueocean - Jenkins Jira
JENKINS-53637Autocomplete plugin does not work in blueocean · Bug. JENKINS-53587Sequential parallel stages show green while still running.
Read more >
minQueryLength="1" and autoComplete - PrimeFaces forum
Now, I click on TireNumber, I press HOME key to position cursor at begin of field and I delete all characters with DELETE...
Read more >
No way to remove google places autocomplete?
Assuming this is how things have been initialised var autocomplete = new google.maps.places.Autocomplete(input, {types: ['geocode']}); ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found