B: Fix validation after setValue

This commit is contained in:
Ivan 2025-02-26 22:10:18 +03:00
parent 41aa6106da
commit 3351ebc637
7 changed files with 9 additions and 9 deletions

View File

@ -76,7 +76,7 @@ export function FormCreateItem() {
function handleFileChange(event: React.ChangeEvent<HTMLInputElement>) { function handleFileChange(event: React.ChangeEvent<HTMLInputElement>) {
if (event.target.files && event.target.files.length > 0) { if (event.target.files && event.target.files.length > 0) {
setValue('file', event.target.files[0]); setValue('file', event.target.files[0]);
setValue('fileName', event.target.files[0].name); setValue('fileName', event.target.files[0].name, { shouldValidate: true });
} else { } else {
setValue('file', undefined); setValue('file', undefined);
setValue('fileName', ''); setValue('fileName', '');
@ -88,7 +88,7 @@ export function FormCreateItem() {
setValue('file', undefined); setValue('file', undefined);
setValue('fileName', ''); setValue('fileName', '');
} }
setValue('item_type', value); setValue('item_type', value, { shouldValidate: true });
} }
function onSubmit(data: ICreateLibraryItemDTO) { function onSubmit(data: ICreateLibraryItemDTO) {

View File

@ -49,7 +49,7 @@ export function TabInputOperation() {
setValue('create_schema', false); setValue('create_schema', false);
setValue('item_data.alias', schema.alias); setValue('item_data.alias', schema.alias);
setValue('item_data.title', schema.title); setValue('item_data.title', schema.title);
setValue('item_data.comment', schema.comment); setValue('item_data.comment', schema.comment, { shouldValidate: true });
} }
return ( return (

View File

@ -17,7 +17,7 @@ export function TabArguments() {
const filtered = oss.items.filter(item => !potentialCycle.includes(item.id)); const filtered = oss.items.filter(item => !potentialCycle.includes(item.id));
function handleChangeArguments(prev: number[], newValue: number[]) { function handleChangeArguments(prev: number[], newValue: number[]) {
setValue('arguments', newValue); setValue('arguments', newValue, { shouldValidate: true });
if (prev.some(id => !newValue.includes(id))) { if (prev.some(id => !newValue.includes(id))) {
setValue('substitutions', []); setValue('substitutions', []);
} }

View File

@ -38,7 +38,7 @@ export function FormCreateCst({ schema }: FormCreateCstProps) {
function handleTypeChange(target: CstType) { function handleTypeChange(target: CstType) {
setValue('cst_type', target); setValue('cst_type', target);
setValue('alias', generateAlias(target, schema)); setValue('alias', generateAlias(target, schema), { shouldValidate: true });
setForceComment(false); setForceComment(false);
} }

View File

@ -23,7 +23,7 @@ export function TabEntityReference() {
const term = selectedCst?.term_resolved ?? ''; const term = selectedCst?.term_resolved ?? '';
function handleSelectConstituenta(cst: IConstituenta) { function handleSelectConstituenta(cst: IConstituenta) {
setValue('entity.entity', cst.alias); setValue('entity.entity', cst.alias, { shouldValidate: true });
} }
return ( return (

View File

@ -14,12 +14,12 @@ export function TabConstituents() {
const { schema } = useRSFormSuspense({ itemID: sourceID! }); const { schema } = useRSFormSuspense({ itemID: sourceID! });
function handleSelectItems(newValue: number[]) { function handleSelectItems(newValue: number[]) {
setValue('items', newValue); setValue('items', newValue, { shouldValidate: true });
const newSubstitutions = substitutions.filter( const newSubstitutions = substitutions.filter(
sub => newValue.includes(sub.original) || newValue.includes(sub.substitution) sub => newValue.includes(sub.original) || newValue.includes(sub.substitution)
); );
if (newSubstitutions.length !== substitutions.length) { if (newSubstitutions.length !== substitutions.length) {
setValue('substitutions', newSubstitutions); setValue('substitutions', newSubstitutions, { shouldValidate: true });
} }
} }

View File

@ -42,8 +42,8 @@ export function DlgRenameCst() {
} }
function handleChangeType(newType: CstType) { function handleChangeType(newType: CstType) {
setValue('alias', generateAlias(newType, schema));
setValue('cst_type', newType); setValue('cst_type', newType);
setValue('alias', generateAlias(newType, schema), { shouldValidate: true });
} }
return ( return (