Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions specifyweb/frontend/js_src/lib/components/partialdateui.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,10 @@ export function PartialDateUi<SCHEMA extends AnySchema>({
}
if (typeof moment === 'undefined') {
resource.set(dateField, null as never);
if (precisionField !== undefined)
if (
precisionField !== undefined &&
typeof resource.get(precisionField) !== 'number'
)
resource.set(precisionField, null as never);
resource.saveBlockers?.remove(`invaliddate:${dateField}`);
} else if (moment.isValid()) {
Expand Down Expand Up @@ -326,9 +329,11 @@ export function PartialDateUi<SCHEMA extends AnySchema>({
const precision = target.value as PartialDatePrecision;
setPrecision(precision);
const precisionIndex = precisions[precision];
if (typeof precisionField === 'string')
if (
typeof moment === 'object' &&
typeof precisionField === 'string'
)
resource.set(precisionField, precisionIndex as never);
resource.saveBlockers?.remove(`invaliddate:${dateField}`);
}}
onBlur={(): void => {
if (typeof moment === 'undefined') return;
Expand Down