Skip to content

Commit 6228fe4

Browse files
author
Nathan Reyes
committed
Prevent bug causing infinite update cycle loop and locking the browser when using . Closes #61.
1 parent 18204a1 commit 6228fe4

File tree

5 files changed

+27
-35
lines changed

5 files changed

+27
-35
lines changed

CHANGELOG.md

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,25 @@
1-
# v0.6.0
1+
# v0.6.1
22
## Bug Fixes
3+
`v-date-picker`
4+
* Prevent bug causing infinite update cycle loop and locking the browser when using `disabled-dates`. Closes #61.
5+
6+
## Improvements
7+
`v-calendar`
8+
* Improve efficiency of date intersection detection logic.
39

10+
# v0.6.0
11+
## Bug Fixes
412
`v-date-picker`
513
* Bug: `fromPage` and `toPage` not updating when new date was assigned or selected.
614
Fix: `fromPage` and `toPage` are updated when new value is assigned, if needed. Closes #51.
715
* Bug: When clearing out input element, infinite start and end dates selected.
816
Fix: When clearing out input element, date is cleared or reverts to previous value, depending on `is-required` prop or if dragging in `"range"` mode. Closes #54.
917

1018
## Improvements
11-
1219
* Add Finnish translation to locales
13-
1420
`v-calendar`
15-
### Props
16-
* Rename `popover-header` slot name to `day-popover-header` to more clearly identify slot target
1721
### Slots
22+
* Rename `popover-header` slot name to `day-popover-header` to more clearly identify slot target
1823
* Add `day-popover-footer` slot for day popover footers
1924
* `day-popover-header`, `day-popover-footer` and custom popover slots accept `day` prop instead of `day-info` prop
2025
### Events

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "v-calendar",
3-
"version": "0.6.0",
3+
"version": "0.6.1",
44
"description": "A clean and extendable plugin for building simple attributed calendars in Vue.js.",
55
"keywords": [
66
"vue",
@@ -13,7 +13,7 @@
1313
"bars",
1414
"indicators"
1515
],
16-
"homepage": "https://vcalendar.netlify.com",
16+
"homepage": "https://vcalendar.io",
1717
"author": "Nathan Reyes <[email protected]>",
1818
"main": "lib/v-calendar.min.js",
1919
"files": [

src/components/DatePicker.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ export default {
155155
...(this.disabledAttribute || resolveDefault(defaults.datePickerDisabledAttribute, this.attributeParams)),
156156
dates: this.disabledDates_,
157157
excludeDates: this.availableDates,
158+
excludeMode: 'includes',
158159
});
159160
},
160161
inputProps_() {
@@ -333,7 +334,8 @@ export default {
333334
// Keep the popover open because something they entered was modified
334335
this.disablePopoverForceHidden = true;
335336
}
336-
this.$emit('input', filteredValue);
337+
// Emit event to update value if it has changed
338+
if (!this.profile.valuesAreEqual(filteredValue, this.value)) this.$emit('input', filteredValue);
337339
// Blur the input if it is visible
338340
if (this.$refs.input) this.$refs.input.blur();
339341
// Update input text for good measure

src/components/DateRangePicker.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ export default {
118118
}
119119
},
120120
dateIsValid(date) {
121-
return !(this.disabledAttribute && this.disabledAttribute.intersectsDate(date));
121+
return !this.disabledAttribute || !this.disabledAttribute.intersectsDate(date);
122122
},
123123
},
124124
};

src/utils/attribute.js

Lines changed: 11 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ const Attribute = (config) => {
1010
if (config.excludeDates && !isArray(config.excludeDates)) config.excludeDates = [config.excludeDates];
1111
const hasDates = arrayHasItems(config.dates);
1212
const hasExcludeDates = arrayHasItems(config.excludeDates);
13+
const excludeMode = config.excludeMode || 'intersects';
1314
const dates =
1415
(
1516
(hasDates && config.dates) || // Use provided dates if they have items
@@ -33,35 +34,19 @@ const Attribute = (config) => {
3334
dates,
3435
excludeDates,
3536
isComplex,
36-
// Any date partly intersects with given date
37-
intersectsDate: date => dates.find((d) => {
38-
// Date doesn't match
39-
if (!d.intersectsDate(date)) return null;
40-
// No exclude dates to check - just return first match
41-
if (!hasExcludeDates) return d;
42-
// Return match date if test date doesn't intersect any excluded dates
43-
return excludeDates.find(ed => ed.intersectsDate(date)) ? false : d;
44-
}) || false,
4537
// Accepts: Date or date range object
46-
// Returns: First attribute date info that occurs on given date
47-
includesDate: date => dates.find((d) => {
48-
// Date doesn't match
49-
if (!d.includesDate(date)) return null;
50-
// No exclude dates to check - just return first match
51-
if (!hasExcludeDates) return d;
52-
// Return match date if test date doesn't intersect any excluded dates
53-
return excludeDates.find(ed => ed.intersectsDate(date)) ? false : d;
54-
}) || false,
38+
// Returns: First attribute date info that partially intersects the given date
39+
intersectsDate: date => !attr.excludesDate(date) && (dates.find(d => d.intersectsDate(date)) || false),
40+
// Accepts: Date or date range object
41+
// Returns: First attribute date info that completely includes the given date
42+
includesDate: date => !attr.excludesDate(date) && (dates.find(d => d.includesDate(date)) || false),
43+
excludesDate: date => hasExcludeDates && excludeDates.find(ed =>
44+
(excludeMode === 'intersects' && ed.intersectsDate(date)) ||
45+
(excludeMode === 'includes' && ed.includesDate(date))),
5546
// Accepts: Day object
5647
// Returns: First attribute date info that occurs on given day.
57-
includesDay: day => dates.find((d) => {
58-
// Date doesn't match
59-
if (!d.includesDay(day)) return null;
60-
// No exclude dates to check - just return first match
61-
if (!hasExcludeDates) return d;
62-
// Return match date if test day doesn't intersect any excluded dates
63-
return excludeDates.find(ed => ed.includesDay(day)) ? false : d;
64-
}) || false,
48+
includesDay: day => !attr.excludesDay(day) && (dates.find(d => d.includesDay(day)) || false),
49+
excludesDay: day => hasExcludeDates && excludeDates.find(ed => ed.includesDay(day)),
6550
};
6651
mixinOptionalProps(config, attr, [
6752
{ name: 'highlight', mixin: defaults.highlight },

0 commit comments

Comments
 (0)