Skip to content

Commit e40d8de

Browse files
committed
refactor: Change min and max check in selection grid
1 parent 354aea0 commit e40d8de

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

src/VueDatePicker/components/SelectionGrid.vue

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -173,12 +173,22 @@
173173
* Check if value is within min-max range
174174
*/
175175
const checkMinMaxValue = (value: number | string): boolean => {
176-
if (props.maxValue === null && props.minValue === null) return false;
176+
const hasMax = props.maxValue || props.maxValue === 0;
177+
const hasMin = props.minValue || props.minValue === 0;
178+
if (!hasMax && !hasMin) return false;
177179
178-
const isAboveMax = props.maxValue || +props.maxValue === 0 ? +value > +props.maxValue : false;
179-
const isBellowMin = props.minValue || +props.minValue === 0 ? +value < +props.minValue : false;
180+
if (hasMax && hasMin) {
181+
return +value > +props.maxValue || +value < +props.minValue;
182+
}
183+
if (hasMax) {
184+
return +value > +props.maxValue;
185+
}
186+
187+
if (hasMin) {
188+
return +value < +props.minValue;
189+
}
180190
181-
return isAboveMax || isBellowMin;
191+
return false;
182192
};
183193
184194
/**

0 commit comments

Comments
 (0)