Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolves front-end bug in 'customize_form.js', triggered by delete actions on child-tables #26344

Open
wants to merge 6 commits into
base: version-15-hotfix
Choose a base branch
from

Conversation

karanwilson
Copy link

closes #26041

The following video (uploaded by the user who opened the issue) demonstrates the bug:-
https://github.com/frappe/frappe/assets/48678570/09351117-66bd-4934-a58a-9630f836c522

The bug affects the following 3 child tables in the Customize Form view:-
"DocType Link"
"DocType Action"
"DocType State"

The issue emerges when we try to delete any rows that are added to the above child tables in the Doctype opened via the Customize Form.

After debugging and tracing the ecosystem of the issue, it is found that:-
the exception occurs when the delete function removes rows of the above mentioned child tables (of their respective parent doctype) from the local copy of the browser.
As per design, this works fine in the case of Doctype edits, but in the case of Customise Form edits, the 'parent' doc of the opened Form view, is 'Customize Form', which is different from the 'parent' of the child table that is being edited.
Hence the delete does not reflect on the opened form, and the grid_row of the child table become 'undefined'.

The fix:-
Replicate the changed child-table field of the 'parent' doctype, to the opened child-table field of 'Customise-Form'.
(frm.doc.links = parent_doc.links;)
Please refer to the commit message, for full details.

@karanwilson
Copy link
Author

karanwilson commented May 7, 2024

Hi @akhilnarang,
based on the recent workflow feedback, I have defined the variables 'parenttype' and 'parent' locally within customize_form.js
Requesting a re-run of the workflow.

@karanwilson
Copy link
Author

Dear @akhilnarang,
Please advise if any more changes are needed.

frappe#26041

In refresh_field(fieldname, txt) function of grid_row.js, added the comments :-
    // the below if statement is added to factor in the exception when this.doc is undefined -
    // - after row removals via customize_form.js on links, actions and states child-tables
    if (this.doc)
            field.docname = this.doc.name;
In customize_form.js :-
defined parent and parenttype as local variables in the event functions for child tables links, actions and states
@karanwilson
Copy link
Author

karanwilson commented May 11, 2024

Hi @akhilnarang, thanks for the re-run of the workflows;

I have fixed the spacing for 'Prettier', and the 'Commit Titles' now.

Requesting help in understanding the 3rd test that hadn't succeeded:-
UI, Attempt # 2 / UI Tests (Cypress) (3)

Running: cypress/integration/control_link.js
9 passing (3m)
1 failing

  1. Control Link
    show text for Gender link field with language en:
    CypressError: Timed out retrying after 30000ms: cy.wait() timed out waiting 30000ms for the 1st response to the route: search_link. No response ever occurred.

I have not made any changes relating to this UI (3rd) test - please advise.

@karanwilson
Copy link
Author

karanwilson commented May 15, 2024

Dear @akhilnarang,
Now all checks were successful;
Please advise whether I should troubleshoot the cypress UI error while running:-
cypress/integration/control_link.js

field.docname = this.doc.name;
// the below if statement is added to factor in the exception when this.doc is undefined -
// - after row removals via customize_form.js on links, actions and states child-tables
if (this.doc) field.docname = this.doc.name;
Copy link
Member

Choose a reason for hiding this comment

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

@karanwilson the rest seems fine, in what case was this needed? (field being defined but doc undefined)

Copy link
Author

Choose a reason for hiding this comment

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

Hi @akhilnarang, when a grid-row/child-table row (for links, actions, states) is deleted using a 'Customize Form' view, then the deleted grid-row document (this.doc) in locals (browser copy of the doctype) becomes undefined, because that particular row gets deleted - in this case when the refresh_field method in grid_row.js is called, the browser console throws a silent error mentioning that this.doc is undefined (in statement 1441 above), where field.docname is assigned the value from this.doc.name

Having the if condition does not run the field.docname assignment statement, when the refresh_field method is called after row-deletes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants