stalefish 8.0.7 → 8.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -154,7 +154,21 @@ export default ({ wrapperStyle = null, holdingPen, label, placeholder, property,
|
|
|
154
154
|
e.target.parentNode.parentNode._flatpickr.close()
|
|
155
155
|
return false
|
|
156
156
|
}}>clear</div>` : ''}
|
|
157
|
-
<input data-gramm="false" ?disabled=${disabled} style="${disabled ? 'cursor: not-allowed; opacity: 0.3;' : ''}" class="${styles.textfield} ${fieldIsTouched(holdingPen, property) === true ? styles.touched : ''}" ${required ? { required: 'required' } : ''} onchange=${e => {
|
|
157
|
+
<input data-gramm="false" ?disabled=${disabled} style="${disabled ? 'cursor: not-allowed; opacity: 0.3;' : ''}" class="${styles.textfield} ${fieldIsTouched(holdingPen, property) === true ? styles.touched : ''}" ${required ? { required: 'required' } : ''} onchange=${e => {
|
|
158
|
+
// Guard against re-render while Flatpickr popup is open: native input onchange
|
|
159
|
+
// can fire on spinner clicks, which would propagate to the parent onchange
|
|
160
|
+
// and trigger a re-render tearing down the popup. If the picker is open,
|
|
161
|
+
// ignore this native onchange and let flatpickr's onClose handler sync state.
|
|
162
|
+
const wrapperEl = e.target && e.target.parentNode && e.target.parentNode.parentNode
|
|
163
|
+
const fp = wrapperEl && wrapperEl._flatpickr
|
|
164
|
+
if (fp && fp.isOpen) {
|
|
165
|
+
e.stopPropagation()
|
|
166
|
+
e.preventDefault()
|
|
167
|
+
return false
|
|
168
|
+
}
|
|
169
|
+
change({ e, holdingPen, property, label: styles.label })
|
|
170
|
+
onchange && onchange(e)
|
|
171
|
+
}} oninput=${e => { e.target.defaultValue = ''; oninput && oninput(e) }} placeholder="${placeholder || ''}${required ? ' *' : ''}" type="${inputType}" ${pattern ? { pattern } : ''} .value=${holdingPen[property] || ''} data-input />
|
|
158
172
|
</div>
|
|
159
173
|
</div>
|
|
160
174
|
`
|
|
@@ -164,7 +178,7 @@ export default ({ wrapperStyle = null, holdingPen, label, placeholder, property,
|
|
|
164
178
|
// adapter expects a real Element. We defer with requestAnimationFrame and
|
|
165
179
|
// query by id.
|
|
166
180
|
if (typeof window !== 'undefined') {
|
|
167
|
-
const
|
|
181
|
+
const attachNow = () => {
|
|
168
182
|
const wrapperEl = document.getElementById(wrapperId)
|
|
169
183
|
if (!wrapperEl) return
|
|
170
184
|
attachFlatpickr(
|
|
@@ -192,10 +206,7 @@ export default ({ wrapperStyle = null, holdingPen, label, placeholder, property,
|
|
|
192
206
|
onValueUpdate: () => {},
|
|
193
207
|
onClose: (selectedDates, dateString) => {
|
|
194
208
|
const fauxE = {
|
|
195
|
-
currentTarget: {
|
|
196
|
-
validity: { valid: true },
|
|
197
|
-
value: dateString
|
|
198
|
-
}
|
|
209
|
+
currentTarget: { validity: { valid: true }, value: dateString }
|
|
199
210
|
}
|
|
200
211
|
formField(holdingPen, property)(fauxE)
|
|
201
212
|
onchange && onchange(fauxE)
|
|
@@ -205,8 +216,15 @@ export default ({ wrapperStyle = null, holdingPen, label, placeholder, property,
|
|
|
205
216
|
)
|
|
206
217
|
)
|
|
207
218
|
}
|
|
208
|
-
|
|
209
|
-
|
|
219
|
+
|
|
220
|
+
// Try immediate attach if the element is already in the DOM and connected;
|
|
221
|
+
// otherwise, defer to the next frame as a fallback.
|
|
222
|
+
const immediateEl = typeof document !== 'undefined' ? document.getElementById(wrapperId) : null
|
|
223
|
+
if (immediateEl && immediateEl.isConnected) {
|
|
224
|
+
attachNow()
|
|
225
|
+
} else {
|
|
226
|
+
window.requestAnimationFrame(attachNow)
|
|
227
|
+
}
|
|
210
228
|
}
|
|
211
229
|
|
|
212
230
|
return el
|