@@ -356,15 +356,15 @@ function CmsEntryDetailsForm_(
356
356
357
357
async function checkUniqueness ( ) {
358
358
setCheckingUniqueness ( true ) ;
359
- let changedUniqueFields = { } ;
359
+ const changedUniqueFields = { } ;
360
+ /* The field is changed to "pending" before the request.
361
+ If the user changes the field value before the response,
362
+ the status is changed to "not started," and the previous result is ignored. */
360
363
setUniqueFieldStatus ( ( prev ) => {
361
364
const copy = { ...prev } ;
362
365
Object . entries ( copy ) . map ( ( [ fieldIdentifier , fieldStatus ] ) => {
363
366
if ( fieldStatus . status === "not started" ) {
364
- changedUniqueFields = {
365
- ...changedUniqueFields ,
366
- [ fieldIdentifier ] : fieldStatus . value ,
367
- } ;
367
+ changedUniqueFields [ fieldIdentifier ] = fieldStatus . value ;
368
368
fieldStatus . status = "pending" ;
369
369
}
370
370
} ) ;
@@ -378,11 +378,11 @@ function CmsEntryDetailsForm_(
378
378
) ;
379
379
setUniqueFieldStatus ( ( prev ) => {
380
380
const copy = { ...prev } ;
381
- uniqueFieldsCheck . forEach ( ( uniqueFieldCheck ) => {
382
- const field = copy [ uniqueFieldCheck . fieldIdentifier ] ;
383
- if ( field . status === "pending" ) {
384
- field . status = uniqueFieldCheck . ok ? "ok" : "violation" ;
385
- field . conflictEntryIds = uniqueFieldCheck . conflictRowIds ;
381
+ uniqueFieldsCheck . forEach ( ( uniqueCheck ) => {
382
+ const identifier = uniqueCheck . fieldIdentifier ;
383
+ if ( copy [ identifier ] . status === "pending" ) {
384
+ copy [ identifier ] . status = uniqueCheck . ok ? "ok" : "violation" ;
385
+ copy [ identifier ] . conflictEntryIds = uniqueCheck . conflictRowIds ;
386
386
}
387
387
} ) ;
388
388
return copy ;
0 commit comments