Skip to content

Conversation

@anna-shakhova
Copy link
Contributor

No description provided.

@anna-shakhova anna-shakhova self-assigned this Oct 28, 2025
Copilot AI review requested due to automatic review settings October 28, 2025 09:30
@anna-shakhova anna-shakhova requested a review from a team as a code owner October 28, 2025 09:30
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes a bug in the Form component's itemOption method when retrieving items by path where multiple items share the same name or caption (T1311534). The fix ensures path-based lookups correctly traverse nested groups and return the intended item rather than the first matching name.

Key changes:

  • Fixed the _getFieldParts method to correctly reverse the path array after splitting
  • Added validation in _getItemByFieldPath to ensure the path node matches before retrieving nested items
  • Changed return types from false to null for consistency with TypeScript conventions

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
packages/devextreme/testing/tests/DevExpress.ui.widgets.form/form.tests.js Added test case verifying itemOption retrieves correct items by path when duplicates exist
packages/devextreme/js/__internal/ui/form/form.utils.ts Changed return type from false to null for consistency
packages/devextreme/js/__internal/ui/form/form.ts Fixed path parsing logic and added path validation to prevent incorrect item matching

Copilot AI review requested due to automatic review settings October 28, 2025 12:27
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

Copilot AI review requested due to automatic review settings October 29, 2025 08:12
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

return {
fieldName,
fieldPath: resultPath.reverse(),
fieldPath,
Copy link

Copilot AI Oct 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The _getFieldParts method incorrectly reverses the fieldPath. When splitting 'a.b.c', it becomes ['c', 'b', 'a'], then destructuring gives fieldName='c' and fieldPath=['b', 'a']. However, the return statement doesn't reverse fieldPath back, so it's returned as ['b', 'a'] instead of ['a', 'b']. The old implementation at line 1498 explicitly reversed the path with resultPath.reverse(). This bug will cause path traversal to fail when looking up nested items.

Suggested change
fieldPath,
fieldPath: fieldPath.reverse(),

Copilot uses AI. Check for mistakes.

const editorLabelText = 'Item 1';

const resultLabelMode = formLabelMode;
Copy link

Copilot AI Oct 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test removed the editorLabelMode parameter when determining resultLabelMode (line 224). The original code at line 1551 in form.tests.js used editorLabelMode || formLabelMode, but the new code only uses formLabelMode. This changes the test logic and may cause incorrect assertions when editorLabelMode is specified but different from formLabelMode.

Suggested change
const resultLabelMode = formLabelMode;
const editorLabelMode = $form.dxForm('option', 'items')[0].label?.labelMode;
const resultLabelMode = editorLabelMode || formLabelMode;

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant