diff --git a/CHANGELOG.md b/CHANGELOG.md index 609f41fe85bf3a5c327907c17d1406c9724fb1b1..b514f51041341e462010e49cbaeb23e12df92943 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -59,6 +59,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Updated the path to python for DL models inside automatic annotation documentation () - Fixed of receiving function variable () - Shortcuts with CAPSLOCK enabled and with non-US languages activated () +- Fixed label editor name field validator () ### Security diff --git a/cvat-ui/src/components/labels-editor/label-form.tsx b/cvat-ui/src/components/labels-editor/label-form.tsx index c0f78329a53c37143349b0f7a24003ba525aa0a4..23f16c962c68a6bff44ebbc265446d0eb83bf24f 100644 --- a/cvat-ui/src/components/labels-editor/label-form.tsx +++ b/cvat-ui/src/components/labels-editor/label-form.tsx @@ -390,10 +390,11 @@ export default class LabelForm extends React.Component { message: patterns.validateAttributeName.message, }, { - validator: async (_rule: any, labelName: string, callback: Function) => { + validator: (_rule: any, labelName: string) => { if (labelNames && labelNames.includes(labelName)) { - callback('Label name must be unique for the task'); + return Promise.reject(new Error('Label name must be unique for the task')); } + return Promise.resolve(); }, }, ]} @@ -522,7 +523,7 @@ export default class LabelForm extends React.Component { public render(): JSX.Element { return (
- + {this.renderLabelNameInput()} {this.renderChangeColorButton()} @@ -531,7 +532,7 @@ export default class LabelForm extends React.Component { {this.renderNewAttributeButton()} - + {this.renderAttributes()} diff --git a/tests/cypress/integration/actions_tasks_objects/case_43_create_label_with_existing_label_name.js b/tests/cypress/integration/actions_tasks_objects/case_43_create_label_with_existing_label_name.js index 198f77889868a9d2db19ac053b9b1268a1c65888..796e41d1a57b6e0348628056addfb8f157ec5de6 100644 --- a/tests/cypress/integration/actions_tasks_objects/case_43_create_label_with_existing_label_name.js +++ b/tests/cypress/integration/actions_tasks_objects/case_43_create_label_with_existing_label_name.js @@ -24,11 +24,10 @@ context('Creating a label with existing label name.', () => { // Try to create a label with existing label name cy.get('.cvat-constructor-viewer-new-item').click(); cy.get('[placeholder="Label name"]').type(firstLabelName); - cy.contains('[type="submit"]', 'Done').click(); + cy.contains('[role="alert"]', 'Label name must be unique for the task') // Checking alert visibility + .should('exist') + .and('be.visible'); }); - cy.get('.cvat-notification-notice-update-task-failed') - .should('exist') - .and('contain.text', 'label names must be unique'); }); }); });