[Feature] Improve Country Search with Weighted Ranking in _filterCountries()
closes #1922
This PR enhances the country search functionality in _filterCountries() by implementing a weighted ranking strategy for search results. The new logic ensures that countries are displayed in the following order based on assigned weightage:
- Countries where the ISO2 code matches the search query exactly.
- Countries whose names start with the search query.
- Countries whose names contain the search query anywhere.
- Countries where the full dial code matches the query.
- Countries where the country initials match the query.
This update significantly improves search result relevance and user experience.
@jackocnr - I hope you’re doing well. When you have a moment, could you kindly review this PR? It is currently blocking our progress, and we would greatly appreciate your feedback. Please let us know if any changes are required, or if everything looks good, we would appreciate your approval.
@jackocnr - I hope you’re doing well. Could you kindly review this PR as soon as possible as it is currently blocking our progress, and we would greatly appreciate your feedback. Please let us know if any changes are required, or if everything looks good, we would appreciate your approval. Thank you!
Hi there, thanks for putting this together - I look forward to reviewing this and hopefully getting it merged and released ASAP. Unfortunately, I have very limited time to commit to open-source over the next month or so, due to life commitments. So most likely I will only get to this in late March. Apologies for the delay. You shouldn't let this block you though - you should just switch to using your version for now, and then later when we get this merged into master, you can switch back again.
Sure, thank you for your comment. We will wait for late march for this to get merged.
Hi @jackocnr - Just wanted to follow up on this PR as it's late March now. Whenever you get a chance, we'd really appreciate your review and feedback. Please let us know if there's anything we can do to help move it forward. Thanks again!
Hi @jackocnr
Just wanted to follow up again as we haven’t heard back yet. We completely understand you may still be busy, but when you get a moment, we’d really appreciate your review on this PR. Please let us know if there’s anything we can do to assist or make things easier. Thanks again for your time!
Hi @jackocnr
Just wanted to follow up again as we haven’t heard back yet. This PR is quite important for us, as we’re currently facing an accessibility issue in our project that depends on this fix. We understand you have a lot on your plate, but if possible, could we request a time-bound review? We’d really appreciate any guidance or feedback if further changes are needed.
Looking forward to hearing from you.
Hii @jackocnr
Just checking in again on this PR. Since it's been a while since our last follow-up. We wanted to kindly ask if there's any update or timeline you could share. We are egger to move forward and happy to make any additional changes if needed. Please let us know if there's anything more we can do on our end.
Thanks for your attention.
Apologies for the delay in getting to this; life has really gotten in the way.
Please could you run the build command npm run build:js and commit those files too. Also, we will need some tests for this new functionality.
Additionally, I think we could make this even better. In your criteria number (4) when the user searches for a dial code, could we respect the country "priority" number when showing results? E.g. if I search +44, and hit Enter, then I select Guernsey, but really, the vast majority of people will be trying to select UK. We already have this data in the country object, under the "priority" key e.g. UK has priority 0, then Guernsey has 1 etc. Does that make sense?
When you build it, you will see ESLint errors - you should be using "const" instead of "let" for all array declarations.
But otherwise it appears to be working well, thanks!
Merged manually. Thanks again for your help on this.