Prestashop: ps_facetedsearch regex does not properly handle spaces on Weight

Created on 26 Nov 2020  路  2Comments  路  Source: PrestaShop/PrestaShop

Describe the bug

Regex /([^\d]*)(?:[\d .,]+)([^\d]+)(?:[\d .,]+)(.*)/ in file \modules\ps_facetedsearch\_dev\front\slider.js on line 29 uses character ' ' instead of '\s' for space, which leads to incorrect group matching behavior in situations where you use space-separated product properties like weight/price, for example: 1 234 (Notice space between 1 and 2). I dont know exactly why, because i'm not a JS-geek or smth, i was just doing my site and wasted good 8 hours diggin into code trying to understand why after enabling filter in my website i see some extra numbers for weight/price filter label. Suddenly i have no time currently to make a proper pull request, because i am only focusing on making theme for my website currently.

Consider this:

min = 180,
max = 24568
unit = "g"

This is displayed as 180g - 24568 568g.
Also, moving slider changes value 24568 instantly, and when finaly mousehold is over, last value also updated, but i believe it had nothing to do with the initial bug and it is just a consequence.

Expected behavior

I expected to see range slider with this filter label:
180g - 24 568g

Steps to Reproduce

Steps to reproduce the behavior:

  1. Set weight property for 1-2 products
  2. Enable weight range filter in Facetedsearch module for main catalogue page
  3. Go to main catalogue page and try to use filter.

Screenshots

Before changing regex pattern:
before

After changing regex pattern to /([^\d]*)(?:[\d\s.,]*)([^\d]*)(?:[\d\s.,]*)([^\d].*)/ directly inside modules\ps_facetedsearch\views\dist\front.js
after

Additional information

  • PrestaShop version: 1.7.6.8
  • PHP version: 7.2.19-Win32-VC15-x64 (using Laragon environment on windows)
1.7.6.8 Bug FO Faceted search Fixed Major PR available

Most helpful comment

I have to say that is one of the most complete bug reports I have ever seen 馃憦

All 2 comments

I have to say that is one of the most complete bug reports I have ever seen 馃憦

Hi @neonVoice ,
Thanks for the report.

I manage to reproduce this using PS 1.7.6.8 and faceted_search module v3.5.0 and v3.6.0.
Capture d鈥檈虂cran 2020-11-27 a虁 10 02 09

I鈥檒l add this to the debug backlog so that it鈥檚 fixed.
If you have already fixed it on your end or if you think you can do it, please do send us a pull request!

Thanks!

Was this page helpful?
0 / 5 - 0 ratings