fix: Mandatory field bad UX (#16919)
Mandatory fields are highlighted red on page load. It should only highlight if we save the document. **Before:** Form https://user-images.githubusercontent.com/30859809/168791201-049c1de2-b7f5-4dff-bf40-093ff96d4510.mov **After:** Form https://user-images.githubusercontent.com/30859809/168791164-45e2289b-2d2c-4ebb-8b4d-cd2932140572.mov **Before:** Dialog https://user-images.githubusercontent.com/30859809/168791207-800ba9e5-b4eb-419f-8a99-f94916c21c79.mov **After:** Dialog https://user-images.githubusercontent.com/30859809/168791210-f2761d23-3a60-40c2-8aff-2d2cebbd77fa.mov Resolves https://github.com/frappe/frappe/issues/16866
This commit is contained in:
parent
a35098acf7
commit
176518ed2c
8 changed files with 32 additions and 21 deletions
|
|
@ -124,6 +124,5 @@ context('Data Control', () => {
|
|||
cy.get('.actions-btn-group > .btn').contains('Actions').click();
|
||||
cy.get('.actions-btn-group > .dropdown-menu [data-label="Delete"]').click();
|
||||
cy.click_modal_primary_button('Yes');
|
||||
cy.hide_dialog();
|
||||
});
|
||||
});
|
||||
|
|
@ -17,8 +17,8 @@ context('Folder Navigation', () => {
|
|||
//Adding folder (Test Folder)
|
||||
cy.get('.menu-btn-group > .btn').click();
|
||||
cy.get('.menu-btn-group [data-label="New Folder"]').click();
|
||||
cy.get('form > [data-fieldname="value"]').type('Test Folder');
|
||||
cy.findByRole('button', {name: 'Create'}).click();
|
||||
cy.fill_field('value', 'Test Folder');
|
||||
cy.click_modal_primary_button('Create');
|
||||
});
|
||||
|
||||
it('Navigating the nested folders, checking if the URL formed is correct, checking if the added content in the child folder is correct', () => {
|
||||
|
|
@ -32,8 +32,8 @@ context('Folder Navigation', () => {
|
|||
//Adding folder inside the attachments folder
|
||||
cy.get('.menu-btn-group > .btn').click();
|
||||
cy.get('.menu-btn-group [data-label="New Folder"]').click();
|
||||
cy.get('form > [data-fieldname="value"]').type('Test Folder');
|
||||
cy.findByRole('button', {name: 'Create'}).click();
|
||||
cy.fill_field('value', 'Test Folder');
|
||||
cy.click_modal_primary_button('Create');
|
||||
|
||||
//Navigating inside the added folder in the Attachments folder
|
||||
cy.get('[title="Test Folder"] > span').click();
|
||||
|
|
@ -46,26 +46,31 @@ context('Folder Navigation', () => {
|
|||
cy.findByRole('button', {name: 'Add File'}).eq(0).click({force: true});
|
||||
cy.get('.file-uploader').findByText('Link').click();
|
||||
cy.get('.input-group > .form-control').type('https://wallpaperplay.com/walls/full/8/2/b/72402.jpg');
|
||||
cy.findByRole('button', {name: 'Upload'}).click();
|
||||
cy.click_modal_primary_button('Upload');
|
||||
|
||||
//To check if the added file is present in the Test Folder
|
||||
cy.get('span.level-item > span').should('contain', 'Test Folder');
|
||||
cy.get('.list-row-container').eq(0).should('contain.text', '72402.jpg');
|
||||
cy.get('.list-row-checkbox').eq(0).click();
|
||||
|
||||
cy.intercept({
|
||||
method: 'POST',
|
||||
url: 'api/method/frappe.desk.reportview.delete_items'
|
||||
}).as('file_deleted');
|
||||
|
||||
//Deleting the added file from the Test folder
|
||||
cy.findByRole('button', {name: 'Actions'}).click();
|
||||
cy.get('.actions-btn-group [data-label="Delete"]').click();
|
||||
cy.wait(700);
|
||||
cy.findByRole('button', {name: 'Yes'}).click();
|
||||
cy.wait(700);
|
||||
cy.click_modal_primary_button('Yes');
|
||||
cy.wait('@file_deleted');
|
||||
|
||||
//Deleting the Test Folder
|
||||
cy.visit('/app/file/view/home/Attachments');
|
||||
cy.get('.list-row-checkbox').eq(0).click();
|
||||
cy.findByRole('button', {name: 'Actions'}).click();
|
||||
cy.get('.actions-btn-group [data-label="Delete"]').click();
|
||||
cy.findByRole('button', {name: 'Yes'}).click();
|
||||
cy.click_modal_primary_button('Yes');
|
||||
cy.wait('@file_deleted');
|
||||
});
|
||||
|
||||
it('Deleting Test Folder from the home', () => {
|
||||
|
|
@ -74,6 +79,6 @@ context('Folder Navigation', () => {
|
|||
cy.get('.level-left > .list-subject > .file-select >.list-row-checkbox').eq(0).click({force: true, delay: 500});
|
||||
cy.findByRole('button', {name: 'Actions'}).click();
|
||||
cy.get('.actions-btn-group [data-label="Delete"]').click();
|
||||
cy.findByRole('button', {name: 'Yes'}).click();
|
||||
cy.click_modal_primary_button('Yes');
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ context('Kanban Board', () => {
|
|||
|
||||
cy.click_listview_primary_button('Add ToDo');
|
||||
|
||||
cy.fill_field('description', 'Test Kanban ToDo', 'Text Editor');
|
||||
cy.fill_field('description', 'Test Kanban ToDo', 'Text Editor').wait(300);
|
||||
cy.get('.modal-footer .btn-primary').last().click();
|
||||
|
||||
cy.wait('@save-todo');
|
||||
|
|
|
|||
|
|
@ -78,12 +78,5 @@ context('Timeline', () => {
|
|||
cy.get('.page-actions').findByRole('button', {name: 'Actions'}).click();
|
||||
cy.get('.page-actions .actions-btn-group [data-label="Delete"]').click();
|
||||
cy.click_modal_primary_button('Yes');
|
||||
|
||||
//Deleting the custom doctype
|
||||
cy.visit('/app/doctype');
|
||||
cy.select_listview_row_checkbox(0);
|
||||
cy.get('.page-actions').findByRole('button', {name: 'Actions'}).click();
|
||||
cy.get('.page-actions .actions-btn-group [data-label="Delete"]').click();
|
||||
cy.click_modal_primary_button('Yes');
|
||||
});
|
||||
});
|
||||
|
|
@ -341,7 +341,8 @@ Cypress.Commands.add('clear_filters', () => {
|
|||
});
|
||||
|
||||
Cypress.Commands.add('click_modal_primary_button', (btn_name) => {
|
||||
cy.get('.modal-footer > .standard-actions > .btn-primary').contains(btn_name).trigger('click', {force: true});
|
||||
cy.wait(400);
|
||||
cy.get('.modal-footer > .standard-actions > .btn-primary').contains(btn_name).click({force: true});
|
||||
});
|
||||
|
||||
Cypress.Commands.add('click_sidebar_button', (btn_name) => {
|
||||
|
|
|
|||
|
|
@ -159,6 +159,13 @@ frappe.ui.form.ControlInput = class ControlInput extends frappe.ui.form.Control
|
|||
this.$wrapper.find(".help-box").html("");
|
||||
}
|
||||
set_mandatory(value) {
|
||||
// do not set has-error class on form load
|
||||
if (this.frm && this.frm.cscript && this.frm.cscript.is_onload) return;
|
||||
|
||||
// do not set has-error class while dialog is rendered
|
||||
// set has-error if dialog primary button is clicked
|
||||
if (this.layout && this.layout.is_dialog && !this.layout.primary_action_fulfilled) return;
|
||||
|
||||
this.$wrapper.toggleClass("has-error", Boolean(this.df.reqd && is_null(value)));
|
||||
}
|
||||
set_invalid () {
|
||||
|
|
|
|||
|
|
@ -312,8 +312,10 @@ frappe.ui.form.ControlLink = class ControlLink extends frappe.ui.form.ControlDat
|
|||
}
|
||||
let value = me.get_input_value();
|
||||
let label = me.get_label_value();
|
||||
let last_value = me.last_value || "";
|
||||
let last_label = me.label || "";
|
||||
|
||||
if (value !== me.last_value || me.label !== label) {
|
||||
if (value !== last_value || label !== last_label) {
|
||||
me.parse_validate_and_set_in_model(value, null, label);
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -105,6 +105,10 @@ frappe.ui.FieldGroup = class FieldGroup extends frappe.ui.form.Layout {
|
|||
|
||||
if (!is_null(v)) ret[f.df.fieldname] = v;
|
||||
}
|
||||
|
||||
if (this.is_dialog && f.df.reqd && !f.value) {
|
||||
f.refresh_input();
|
||||
}
|
||||
}
|
||||
if (errors.length && !ignore_errors) {
|
||||
frappe.msgprint({
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue