Update date picker to fix horrible flatpickr event handling
This commit is contained in:
parent
f59e39931b
commit
876ec44d11
|
@ -37,7 +37,9 @@
|
||||||
// duplicate input field.
|
// duplicate input field.
|
||||||
// We need to blur both because the focus styling does not get properly
|
// We need to blur both because the focus styling does not get properly
|
||||||
// applied.
|
// applied.
|
||||||
const els = document.querySelectorAll(`#${$fieldState.id}-wrapper input`)
|
const els = document.querySelectorAll(
|
||||||
|
`#${$fieldState.fieldId}-wrapper input`
|
||||||
|
)
|
||||||
els.forEach(el => el.blur())
|
els.forEach(el => el.blur())
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
@ -51,9 +53,9 @@
|
||||||
on:close={onClose}
|
on:close={onClose}
|
||||||
options={flatpickrOptions}
|
options={flatpickrOptions}
|
||||||
on:change={handleChange}
|
on:change={handleChange}
|
||||||
element={`#${$fieldState.id}-wrapper`}>
|
element={`#${$fieldState.fieldId}-wrapper`}>
|
||||||
<div
|
<div
|
||||||
id={`${$fieldState.id}-wrapper`}
|
id={`${$fieldState.fieldId}-wrapper`}
|
||||||
aria-disabled="false"
|
aria-disabled="false"
|
||||||
aria-invalid="false"
|
aria-invalid="false"
|
||||||
class="flatpickr spectrum-InputGroup spectrum-Datepicker"
|
class="flatpickr spectrum-InputGroup spectrum-Datepicker"
|
||||||
|
@ -61,14 +63,16 @@
|
||||||
aria-readonly="false"
|
aria-readonly="false"
|
||||||
aria-required="false"
|
aria-required="false"
|
||||||
aria-haspopup="true">
|
aria-haspopup="true">
|
||||||
<div class="spectrum-Textfield spectrum-InputGroup-textfield">
|
<div
|
||||||
|
on:click={flatpickr?.open}
|
||||||
|
class="spectrum-Textfield spectrum-InputGroup-textfield">
|
||||||
<input
|
<input
|
||||||
data-input
|
data-input
|
||||||
type="text"
|
type="text"
|
||||||
class="spectrum-Textfield-input spectrum-InputGroup-input"
|
class="spectrum-Textfield-input spectrum-InputGroup-input"
|
||||||
aria-invalid="false"
|
aria-invalid="false"
|
||||||
{placeholder}
|
{placeholder}
|
||||||
id={$fieldState.id}
|
id={$fieldState.fieldId}
|
||||||
value={$fieldState.value} />
|
value={$fieldState.value} />
|
||||||
</div>
|
</div>
|
||||||
<button
|
<button
|
||||||
|
@ -86,10 +90,19 @@
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</Flatpickr>
|
</Flatpickr>
|
||||||
|
{#if open}
|
||||||
|
<div class="overlay" on:mousedown|self={flatpickr?.close} />
|
||||||
|
{/if}
|
||||||
{/if}
|
{/if}
|
||||||
</SpectrumField>
|
</SpectrumField>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
|
.spectrum-Textfield-input {
|
||||||
|
pointer-events: none;
|
||||||
|
}
|
||||||
|
.spectrum-Textfield:hover {
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
.flatpickr {
|
.flatpickr {
|
||||||
width: var(
|
width: var(
|
||||||
--spectrum-alias-single-line-width,
|
--spectrum-alias-single-line-width,
|
||||||
|
@ -99,4 +112,12 @@
|
||||||
.flatpickr .spectrum-Textfield {
|
.flatpickr .spectrum-Textfield {
|
||||||
width: auto;
|
width: auto;
|
||||||
}
|
}
|
||||||
|
.overlay {
|
||||||
|
position: fixed;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
width: 100vw;
|
||||||
|
height: 100vh;
|
||||||
|
z-index: 999;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
Loading…
Reference in New Issue