Commit 7cca9a4
committed
fix(numericRefinementList): Correctly apply active class
Fixes #1010
The `shouldComponentUpdate` of `RefinementList` was checking if the
`facetValues` from the props where actually changed before issuing
a new rendering. It turns out that in `numericRefinementList`, the
new `facetValues` was always equal to the already set one. More
precisely, the filters seemed to already be set in the props before
reaching `shouldComponentUpdate`.
Turns out that we were editing a variable in place instead of working
on a copy so the internal props where changing without the component
really noticing.
I updated the `render` method of the `numericRefinementList` to pass
a new array instead of working on the same copy over and over again.
I refactored the `shouldComponentUpdate` and `_toggleRefinement`
methods by splitting in several variables in my quest to find the
issue. Thought I might keep it that way.
I added an explicit regression test to make sure we are really not
touching existing variables.
Now the current and next props are really different, and the full
render is propagated and the correct classes applied.# Possible types : feat, fix, refactor, chore, style, perf, test, docs1 parent 6b8e34e commit 7cca9a4
File tree
3 files changed
+37
-8
lines changed- src
- components/RefinementList
- widgets/numeric-refinement-list
- __tests__
3 files changed
+37
-8
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
20 | | - | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
21 | 24 | | |
22 | 25 | | |
23 | 26 | | |
| |||
Lines changed: 23 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
7 | 8 | | |
8 | 9 | | |
9 | 10 | | |
| |||
183 | 184 | | |
184 | 185 | | |
185 | 186 | | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
186 | 209 | | |
187 | 210 | | |
188 | 211 | | |
| |||
Lines changed: 10 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
93 | 93 | | |
94 | 94 | | |
95 | 95 | | |
96 | | - | |
97 | | - | |
98 | | - | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
99 | 100 | | |
100 | 101 | | |
101 | | - | |
102 | | - | |
103 | | - | |
104 | | - | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
105 | 108 | | |
106 | 109 | | |
107 | 110 | | |
| |||
0 commit comments