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.

Chips: stops processing input on the first non-unique pair

See original GitHub issue

Describe the bug

Chips component with unique="true", does not process the whole input, but stops at the first non-unique pair.

Reproducer

  1. Go to https://www.primefaces.org/showcase/ui/input/chips.xhtml
  2. Click on Unique input
  3. Write aaa,aaa,bbb
  4. Press Enter
  5. See error, bbb was not processed

Expected behavior

The whole input must be processed, regardless of the duplicates.

PrimeFaces edition

Community

PrimeFaces version

11.0.0

Theme

All

JSF implementation

All

JSF version

2.3

Browser(s)

All

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
mellowarecommented, May 11, 2022

hmm i am running 12.0-snaphot locally and not seeing that behavior. its working as I would expect.

1reaction
mellowarecommented, May 11, 2022

MonkeyPatch:

if (PrimeFaces.widget.Chips) {
    PrimeFaces.widget.Chips.prototype.addItem = function(value, refocus) {
        var $this = this;

        if (!value || !value.trim().length) {
            return;
        }

        var tokens = value.split(this.cfg.separator);
        for (var i = 0; i < tokens.length; i++) {
            var token = tokens[i];
            if (token && token.trim().length && (!this.cfg.max || this.cfg.max > this.hinput.children('option').length)) {
                var escapedValue = PrimeFaces.escapeHTML(token);

                if (this.cfg.unique) {
                    var duplicateFound = false;
                    this.hinput.children('option').each(function() {
                        if (this.value === escapedValue) {
                            duplicateFound = true;
                            return false; // breaks
                        }
                    });
                    if (duplicateFound) {
                        $this.refocus(refocus);
                        continue;
                    }
                }

                var itemDisplayMarkup = '<li class="ui-chips-token ui-state-active ui-corner-all">';
                itemDisplayMarkup += '<span class="ui-chips-token-icon ui-icon ui-icon-close"></span>';
                itemDisplayMarkup += '<span class="ui-chips-token-label">' + escapedValue + '</span></li>';

                this.inputContainer.before(itemDisplayMarkup);
                this.refocus(refocus);

                this.hinput.append('<option value="' + escapedValue + '" selected="selected"></option>');
                this.invokeItemSelectBehavior(escapedValue);
            }
        }
        $this.updateFloatLabel();
    }
};
Read more comments on GitHub >

github_iconTop Results From Across the Web

ChIP-Seq: advantages and challenges of a maturing technology
Chromatin immunoprecipitation followed by sequencing (ChIP-Seq) is a technique for genome-wide profiling of DNA-binding proteins, ...
Read more >
Counting reads in features with htseq-count
Notice that when using --nonunique all the sum of all counts will not be equal to the number of reads (or read pairs),...
Read more >
ChIP-Seq Data Analysis I: Pre-processing, QC and Primary ...
- Estimate duplicate numbers expected for sequencing depth using negative binomial model and attempt to identify signficantly anomalous duplicate numbers. Page ...
Read more >
Chapter 2: Hardware Basics: Inside the Box - QueGrande.org
C. RAM accepts input; secondary storage devices do not. ... D. the first chip that is accessed when the computer is turned on....
Read more >
CUT&RUNTools: a flexible pipeline for CUT&RUN processing ...
Step 1: input paired-end raw reads are aligned to the reference genome ... First, the sequencing data are processed with Trimmomatic [9], ...
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