Currently joomla-field-fancy-select
uses Choices.js with fuseOptions.threshold = 0.3
.
This causes fuzzy matching even for numeric lists. For example, searching 1043
also returns results like 1003
, 103
, 1031
, etc.
In some cases this behaviour is undesirable when exact matching is required.
I was thinking it might be useful to make the fuseOptions.threshold
configurable through an attribute (e.g. data-fuse-threshold="0"
).
By default it could stay at 0.3
, so the change would be fully backward compatible and not affect existing installations.
File: media/system/js/fields/joomla-field-fancy-select.js
Relevant code:
fuseOptions: {
threshold: 0.3 // Strict search
}
Labels |
Added:
No Code Attached Yet
|
Labels |
Added:
Feature
|
At the moment I’m developing a custom fields plugin where I use a list-fancy-select field containing numeric values. In that case, having a strict mode (even 0.0) would be important. On the other hand, for text searches the fuzzy logic could be indeed useful to balance out typos.
That’s why I thought it might be helpful to make this configurable, while keeping it backwards compatible. Of course, the default value can still be adjusted as needed.
Okay, then it is fine
If need more strict search then we can just reduce default value to let say 0.1 - 0.2.
It was set to 0.3 from default 1 already.
I do not see a need for introducing a new option. But can be added of course.