-
Notifications
You must be signed in to change notification settings - Fork 528
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(range): don't go out of bounds with min or max given #4627
Conversation
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit 01dfce9:
|
Wait, if the one from |
This is indeed correct, but I'm not sure which one of the two should be taken as the source of truth. In theory there's nothing wrong with an out-of-bounds refinement, but then more of the connector is wrong. |
Hmm I thought the min, max bound given to the widget should be the source of truth. In the latest change 404d29d, the out-of-bound refinements are capped with the bound. |
this makes sense I think, although you'll need to change the initial test to make sense |
can you tell me what about the initial test needs to change? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
change is good, but I don't know what the first test is meant to assert
Co-authored-by: Haroen Viaene <[email protected]>
It might be unclear to you. const widget = makeWidget({
attribute: 'price',
min: 0,
max: 500,
});
const actual = widget.getWidgetSearchParameters!(helper.state, {
uiState: {
range: {
price: '0:400',
},
},
});
console.log(actual.numericRefinements.price['<=']); Before this PR, it used to print |
Summary
fixes #4626
This PR fixes the bug where
connectRange
set the wrong range whenmin
ormax
was given.If you look at lines like this,
connectRange
assumes there is only one value per operator (It's getting the first item from the array). However, ingetWidgetSearchParameters
, it adds refinements for min and max bound if given. After that, it again adds the bound fromuiState
.It's reproduced in controlled mode (by calling
setUiState
).Result
It should fixes the reproduction from #4626
The fixed example: https://codesandbox.io/s/confident-pasteur-ocls6?file=/src/app.js