Skip to content

Commit c793baf

Browse files
Label form validator fix (#2879)
* Fixed label form validator * Added CHANGELOG and increased package npm version * Update Cypress test "Creating a label with existing label name" for PR 2879 (#2883) * Fix case 43 for PR 2879 * Try restart CI Co-authored-by: Dmitry Kruchinin <[email protected]>
1 parent 55b20e1 commit c793baf

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
5959
- Updated the path to python for DL models inside automatic annotation documentation (<https://github.com/openvinotoolkit/cvat/pull/2847>)
6060
- Fixed of receiving function variable (<https://github.com/openvinotoolkit/cvat/pull/2860>)
6161
- Shortcuts with CAPSLOCK enabled and with non-US languages activated (<https://github.com/openvinotoolkit/cvat/pull/2872>)
62+
- Fixed label editor name field validator (<https://github.com/openvinotoolkit/cvat/pull/2879>)
6263

6364
### Security
6465

cvat-ui/src/components/labels-editor/label-form.tsx

+5-4
Original file line numberDiff line numberDiff line change
@@ -390,10 +390,11 @@ export default class LabelForm extends React.Component<Props> {
390390
message: patterns.validateAttributeName.message,
391391
},
392392
{
393-
validator: async (_rule: any, labelName: string, callback: Function) => {
393+
validator: (_rule: any, labelName: string) => {
394394
if (labelNames && labelNames.includes(labelName)) {
395-
callback('Label name must be unique for the task');
395+
return Promise.reject(new Error('Label name must be unique for the task'));
396396
}
397+
return Promise.resolve();
397398
},
398399
},
399400
]}
@@ -522,7 +523,7 @@ export default class LabelForm extends React.Component<Props> {
522523
public render(): JSX.Element {
523524
return (
524525
<Form onFinish={this.handleSubmit} layout='vertical' ref={this.formRef}>
525-
<Row justify='start' align='middle'>
526+
<Row justify='start' align='top'>
526527
<Col span={10}>{this.renderLabelNameInput()}</Col>
527528
<Col span={3} offset={1}>
528529
{this.renderChangeColorButton()}
@@ -531,7 +532,7 @@ export default class LabelForm extends React.Component<Props> {
531532
{this.renderNewAttributeButton()}
532533
</Col>
533534
</Row>
534-
<Row justify='start' align='middle'>
535+
<Row justify='start' align='top'>
535536
<Col span={24}>
536537
<Form.List name='attributes'>{this.renderAttributes()}</Form.List>
537538
</Col>

tests/cypress/integration/actions_tasks_objects/case_43_create_label_with_existing_label_name.js

+3-4
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,10 @@ context('Creating a label with existing label name.', () => {
2424
// Try to create a label with existing label name
2525
cy.get('.cvat-constructor-viewer-new-item').click();
2626
cy.get('[placeholder="Label name"]').type(firstLabelName);
27-
cy.contains('[type="submit"]', 'Done').click();
27+
cy.contains('[role="alert"]', 'Label name must be unique for the task') // Checking alert visibility
28+
.should('exist')
29+
.and('be.visible');
2830
});
29-
cy.get('.cvat-notification-notice-update-task-failed')
30-
.should('exist')
31-
.and('contain.text', 'label names must be unique');
3231
});
3332
});
3433
});

0 commit comments

Comments
 (0)