Skip to content

Commit ef56dfa

Browse files
author
vvo
committed
fix(numericSelector): if no currentValue found, use the first option
1 parent e9f6ff7 commit ef56dfa

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/widgets/numeric-selector/__tests__/numeric-selector-test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ describe('numericSelector()', () => {
4444
root: 'ais-numeric-selector custom-root cx',
4545
item: 'ais-numeric-selector--item custom-item'
4646
},
47-
currentValue: undefined,
47+
currentValue: 1,
4848
shouldAutoHideContainer: true,
4949
options: [
5050
{value: 1, label: 'first'},

src/widgets/numeric-selector/numeric-selector.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ function numericSelector({
6060

6161
return {
6262
init({helper}) {
63-
const currentValue = this._getRefinedValue(helper) || options[0].value;
63+
const currentValue = this._getRefinedValue(helper);
6464
if (currentValue !== undefined) {
6565
helper.addNumericRefinement(attributeName, operator, currentValue);
6666
}
@@ -92,7 +92,7 @@ function numericSelector({
9292
const refinedValue = find(refinements, {operator});
9393
return refinedValue &&
9494
refinedValue.value !== undefined &&
95-
refinedValue.value[0] !== undefined ? refinedValue.value[0] : undefined;
95+
refinedValue.value[0] !== undefined ? refinedValue.value[0] : options[0].value;
9696
}
9797
};
9898
}

0 commit comments

Comments
 (0)