Skip to content

Commit d6775aa

Browse files
committed
Fix: adding readonly attribute on instance depend on allowInput value option (default is true)
1 parent 66d78fa commit d6775aa

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "svelte-flatpickr-plus",
3-
"version": "1.0.9",
3+
"version": "1.0.10",
44
"description": "Flatpickr is a lightweight and powerful datetime picker. Svelte Flatpickr Plus is a wrapper for Flatpickr with some extra features.",
55
"homepage": "https://github.com/kodaicoder/svelte-flatpickr-plus",
66
"bugs": {

src/lib/actions.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -200,8 +200,9 @@ function attachFlatpickr(node, opts, plugins = opts.noCalendar ? [] : [new yearD
200200
onOpen: [
201201
async function (selectedDates, dateStr, instance) {
202202
if (instance.altInput) {
203-
instance.altInput.setAttribute('readonly', true);
204-
203+
if (!opts.allowInput) {
204+
instance.altInput.setAttribute('readonly', true);
205+
}
205206
const dayElement = await instance.days;
206207
if (dayElement) {
207208
if (dayElement.querySelector('.today')) {
@@ -211,7 +212,9 @@ function attachFlatpickr(node, opts, plugins = opts.noCalendar ? [] : [new yearD
211212
}
212213
}
213214
} else {
214-
instance.input.setAttribute('readonly', true);
215+
if (!opts.allowInput) {
216+
instance.input.setAttribute('readonly', true);
217+
}
215218
const dayElement = await instance.days;
216219
if (dayElement) {
217220
if (dayElement.querySelector('.today')) {
@@ -229,10 +232,10 @@ function attachFlatpickr(node, opts, plugins = opts.noCalendar ? [] : [new yearD
229232
onClose: [
230233
function (selectedDates, dateStr, instance) {
231234
if (instance.altInput) {
232-
instance.altInput.setAttribute('readonly', false);
235+
instance.altInput.removeAttribute('readonly');
233236
instance.altInput.blur();
234237
} else {
235-
instance.input.setAttribute('readonly', false);
238+
instance.input.removeAttribute('readonly');
236239
instance.input.blur();
237240
}
238241
},

0 commit comments

Comments
 (0)