Skip to content
Open
28 changes: 17 additions & 11 deletions specifyweb/frontend/js_src/lib/components/FormFields/Field.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -204,30 +204,36 @@ function Field({
displayParentCatNumberPlaceHolder,
]);

const customPlaceholder =
displayPrimaryCatNumberPlaceHolder &&
typeof primaryCatalogNumber === 'string'
? primaryCatalogNumber
: displayParentCatNumberPlaceHolder &&
typeof parentCatalogNumber === 'string'
? parentCatalogNumber
: undefined;

const { placeholder: parserPlaceholder, ...restValidationAttributes } =
validationAttributes;

return (
<Input.Generic
forwardRef={validationRef}
key={parser.title}
max={Number.MAX_SAFE_INTEGER}
name={name}
placeholder={
displayPrimaryCatNumberPlaceHolder &&
typeof primaryCatalogNumber === 'string'
? primaryCatalogNumber
: displayParentCatNumberPlaceHolder &&
typeof parentCatalogNumber === 'string'
? parentCatalogNumber
: undefined
}
{...validationAttributes}
placeholder={customPlaceholder ?? parserPlaceholder}
{...restValidationAttributes}
className={rightAlignClassName}
id={id}
isReadOnly={isReadOnly}
required={'required' in validationAttributes && !isInSearchDialog}
tabIndex={isReadOnly ? -1 : undefined}
value={value?.toString() ?? ''}
onBlur={
isReadOnly ? undefined : ({ target }): void => updateValue(target.value)
isReadOnly
? undefined
: ({ target }): void => updateValue(target.value)
}
onValueChange={(value): void => updateValue(value, false)}
/*
Expand Down
2 changes: 1 addition & 1 deletion specifyweb/frontend/js_src/lib/hooks/useResourceValue.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ import type { Input } from '../components/Forms/validationHelpers';
import type { Parser } from '../utils/parser/definitions';
import type { RA } from '../utils/types';
import { useParser } from './resource';
import { useParserDefaultValue } from './useParserDefaultValue';
import { useFieldParser } from './useFieldParser';
import { useFieldValidation } from './useFieldValidation';
import { useParserDefaultValue } from './useParserDefaultValue';

/**
* A hook to integrate an Input with a field on a Backbone resource
Expand Down