Skip to content

Commit e8388e1

Browse files
Stop two-way subscription of browseMonth and browseYear
1 parent a2e421a commit e8388e1

File tree

1 file changed

+12
-14
lines changed

1 file changed

+12
-14
lines changed

src/lib/DatePicker.svelte

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -68,23 +68,14 @@
6868
/** Wait with updating the date until a date is selected */
6969
export let browseWithoutSelecting = false
7070
71-
let browseYear = browseDate.getFullYear()
72-
function getBrowseYear(d: Date) {
73-
browseYear = d.getFullYear()
74-
}
75-
$: getBrowseYear(browseDate)
71+
$: browseYear = browseDate.getFullYear()
7672
function setYear(newYear: number) {
7773
browseDate.setFullYear(newYear)
7874
browseDate = browseDate
7975
browse(browseDate)
8076
}
81-
$: setYear(browseYear)
8277
83-
let browseMonth = browseDate.getMonth()
84-
function getBrowseMonth(d: Date) {
85-
browseMonth = d.getMonth()
86-
}
87-
$: getBrowseMonth(browseDate)
78+
$: browseMonth = browseDate.getMonth()
8879
function setMonth(newMonth: number) {
8980
let newYear = browseDate.getFullYear()
9081
if (newMonth === 12) {
@@ -109,7 +100,6 @@
109100
)
110101
)
111102
}
112-
$: setMonth(browseMonth)
113103
114104
$: calendarDays = getCalendarDays(browseDate, iLocale.weekStartsOn)
115105
@@ -226,7 +216,11 @@
226216
>
227217
</div>
228218
<div class="dropdown month">
229-
<select bind:value={browseMonth} on:keydown={monthKeydown}>
219+
<select
220+
value={browseMonth}
221+
on:keydown={monthKeydown}
222+
on:input={(e) => setMonth(parseInt(e.currentTarget.value))}
223+
>
230224
{#each iLocale.months as monthName, i}
231225
<option
232226
disabled={new Date(browseYear, i, getMonthLength(browseYear, i), 23, 59, 59, 999) <
@@ -252,7 +246,11 @@
252246
>
253247
</div>
254248
<div class="dropdown year">
255-
<select bind:value={browseYear} on:keydown={yearKeydown}>
249+
<select
250+
value={browseYear}
251+
on:input={(e) => setYear(parseInt(e.currentTarget.value))}
252+
on:keydown={yearKeydown}
253+
>
256254
{#each years as v}
257255
<option value={v}>{v}</option>
258256
{/each}

0 commit comments

Comments
 (0)