Comments (3)
how about highlightSelector
as a better name since its really a selector?
from primefaces.
not sure about the name queryHighlightFilter
but i get the idea. It can be span
by default for most scenarios and overridden if necessary.
from primefaces.
For now here is a MonkeyPatch to do what you want for .ui-autocomplete-item-value
if (PrimeFaces.widget.AutoComplete) {
PrimeFaces.widget.AutoComplete.prototype.showSuggestions = function(query) {
this.items = this.panel.find('.ui-autocomplete-item');
this.items.attr('role', 'option');
if (this.cfg.grouping) {
this.groupItems();
}
this.bindDynamicEvents();
var $this = this,
hidden = this.panel.is(':hidden');
if (hidden) {
this.show();
} else {
this.alignPanel();
}
// #8717 always clear list before trying to fill it
if (this.cfg.forceSelection) {
this.currentItems = [];
}
if (this.items.length > 0) {
var firstItem = this.items.eq(0);
//highlight first item
if (this.cfg.autoHighlight && firstItem.length) {
this.highlightItem(firstItem, true);
this.changeAriaValue(firstItem[0]);
}
//highlight query string
if (query.length > 0) {
var cleanedQuery = query.trim().replaceAll(/(\s+)/g, ' ');
if (cleanedQuery.length > 0) {
var queryParts = cleanedQuery.split(' ');
for (var i = 0; i < queryParts.length; i++) {
queryParts[i] = PrimeFaces.escapeRegExp(queryParts[i]);
}
var re = new RegExp('(' + queryParts.join('|') + ')', 'gi');
var isCustomContent = this.panel.children().is('table');
var queryResults = isCustomContent ? this.panel.children().find('.ui-autocomplete-item-value') : this.items;
queryResults.filter(':not(.ui-autocomplete-moretext)').each(function() {
var item = $(this);
var escape = $this.cfg.escape;
var text = escape ? item.html() : item.text();
var escaped_re = escape ? /${PrimeFaces.escapeHTML(text)}/g : /${text}/g;
text = text.replace(escaped_re, '$&');
item.html(text.replace(re, '<span class="ui-autocomplete-query">$&</span>'));
});
}
}
if (this.cfg.forceSelection) {
this.items.each(function(i, item) {
$this.currentItems.push($(item).attr('data-item-label'));
});
}
//show itemtip if defined
if (this.cfg.autoHighlight && this.cfg.itemtip && firstItem.length === 1) {
this.showItemtip(firstItem);
}
this.displayAriaStatus(this.items.length + this.cfg.resultsMessage);
} else {
if (this.cfg.emptyMessage) {
var emptyText = '<div class="ui-autocomplete-empty-message ui-widget">' + PrimeFaces.escapeHTML(this.cfg.emptyMessage) + '</div>';
this.panel.prepend(emptyText);
} else if (!this.cfg.hasFooter) {
this.panel.hide();
}
this.input.removeAttr('aria-activedescendant');
this.displayAriaStatus(this.cfg.ariaEmptyMessage);
}
}
};
from primefaces.
Related Issues (20)
- Can we remove p:resetInput? HOT 9
- DataTable: ALT+W Keyboard Shortcut to AUTO adjust the width of resizeable columns HOT 11
- SelectOneButton: Improve ARIA label handling
- DatePicker: cannot type in datepicker when first displayed (14.0.0) HOT 13
- Confirm: ability to adjust button label and class of global confirmation HOT 9
- org.primefaces.component.remotecommand.*: Wrong component-type and render-type path HOT 6
- CSV: Missing some bean validation keys
- CSV: Test new bean validations
- TreeTable: After quick select deselect the checkboxes of the subtree are still selected HOT 20
- Float Label: Label Doesn't stay Above Field for DatePicker When Left Click Held on a Value HOT 4
- CSV: Date validation requires legacy Calendar
- Wrong Javadoc for InputMaskRenderer#translateMaskIntoRegex() HOT 6
- TabMenu: Incorrect border classes applied
- DatePicker: yearNavigator is no longer rendered as a dropdown HOT 5
- DataTable: Allow using custom icons for p:rowToggler HOT 3
- InputMask: slotChar as optional HOT 13
- Confirm: message facet HOT 5
- jakarta and facelet-taglib version HOT 5
- Confirm: event.currentTarget is the incorrect button HOT 2
- AutoComplete: Float label and multiple="true" not working
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from primefaces.